i
WebDriver Introduction
Selenium WebDriver Architecture
Introduction to WebDriver API
Introduction to WebDriver – Code
Handling Dropdowns and Select class
Handling Multiple Dropdown values and Links
Handling Radio buttons and Checkboxes
Capture Screenshots and Email test results
Browser Navigation Methods
Handling tabs
Capturing screenshot, Handling tabs and pop-ups – Code
Handling tabs and Pop-ups – Code
Handling Alerts
Handling User Authentication and Input alerts
HtmlUnitDriver and Handling Captchas
Handling Web Tables
Synchronization
Handling WebTables, Synchronization issues, Firefoxprofiles – Code
Actions Class
Event Listeners, Event Firing Mouse, Coordinates – Code
Handling Mouse Hover in Selenium
JavascriptExecutor
Handling Iframes
IsElementPresent, IsEnabled, IsSelected
Working with Chrome Driver - Part 1
Working with FireFox Driver - Part 2
Working with Internet Explorer Driver - Part 3
Handling SSL Certificate
Desired Capabilities
How to Encode password in WebDriver
Handling JQuery Elements - Drag and Drop, Sliders, Resizable
Handling JQuery Elements - Drag and Drop, Sliders, Resizable – Code
Working on IE Browser using Actions
TestNG, Ant & Report Generation through XSLT
Introduction to TestNG and Annotations
TestNG Parameterization
Configuring ANT, Generating TestNG & XSLT Reports
Code for generating XSLT / Surefire Reports through MAVEN
TestNG Parameterization Excel Reading
Handling Multiple data providers
TestNG XSLT Jar, Build.xml & TestNG.xml file
Frameworks Introduction
Hybrid (DATA + KEYWORD) driven Framework
Framework Architecture
Reading Excel sheets
TestNG DataProvider
Data Provider with Hashtable
Handling Multiple Test Suites
Multiple DataProviders
Setting up Run-modes at Suite Level
Setting up Runmodes at TestCase Level
Creating a common utility for Run-modes
Hybrid Framework Code
We usually do the Selenium test automation on popular web browsers like IE, Chrome, Firefox, Safari. Validating the tests in web browser is clearly visible to the user during the automation run. User can see the test running in browser UI smoothly. But in some cases, the user needs to run the test cases without any GUI, and this means test run should not be visible to the user on any browser, but the test gets executed successfully.
We can achieve this by using "Headless Browsers". A headless browser does not have any GUI, and it works in the background. There are different types of the headless driver available to handle this kind of situation. The most widely used headless driver is "HtmlUnitDriver”.
We can use the “HtmlUnitDriver" latest maven dependencies to get its libraries into our project. We can paste below the dependency in the POM.xml file.
org.seleniumhq.selenium
htmlunit-driver
2.34.0
There are various dependencies available on maven platform but try to use which comes with htmlunit-driver .
Once the jar is loaded to the project, we can start instantiating the HtmlUnitDriver object to load the URL without any browser UI. Let us see the complete code of the same:
package SeleniumTest.SeleniumTest;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class HeadlessBrowser
{
public static void main( String[] args )
{
System.setProperty("webdriver.chrome.driver","C:\\Users\\AC42610\\chromedriver.exe");
WebDriver driver=new HtmlUnitDriver();
driver.get("https://selflearning.io/");
System.out.println(driver.getTitle());
}
}
This code prints the console with the text "Self Learning | Online Tutorials | Mock Test | Old Papers | Study Material | Quiz | Video Lectures".
Handling Captchas:
To be very frank on this, Captcha should not be automated at all. CAPTCHA is a backronym for "Completely Automated Public Turing test to tell Computers and Human Apart”.
This means that Captcha is a protection against any automated software to avoid the automated loading of web pages. If we do automation of Captcha, then the purpose of having a captcha is itself worthless.
Now the question comes, how to handle this situation for testing such scenarios?
We can have a set of workarounds to handle this situation:
There could be a variety of workaround to handle this situation, but there is one thing that must be taken care that the whole concept of having Captcha is to prevent the web page from any automated tool. So, if we are using point a or b for handling this situation, we must take care to get the rollback to original code to make sure the correct code pushed to production.
Don't miss out!