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
Now we have got an understanding of WebDriver and its architecture. We can start using the same for the starting automation of web pages. As we have discussed in previous topics of WebDriver that WebDriver provides a channel of communication between tester and browser with the help of a tester’s code and browser driver.
Let us start with a simple piece of code that opens the www.selflearning.io web page and fetches the element text from the "Testing" tab on the home page.
First, we must import all the required selenium packages to start with the first WebDriver code. Once packages are imported, we need to set the system property to define the browser driver path using the setProperty() method of System class.
Now we are ready to create a browser driver's object by taking reference to the WebDriver interface. Now the driver object can be used to navigate to the web page in the browser. Once we are landed on the web browser, we can locate the web element using the findElement() method of the SearchContext interface. We may discuss more on the findElement() method in detail later in this series.
findElement() method returns a WebElement type. Now we can use this returned value to fetch the text from this located element.
package SeleniumTest.SeleniumTest;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class WebDriverTest
{
public static void main( String[] args )
{
System.setProperty("webdriver.chrome.driver","C:\\Users\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("https://selflearning.io/");
WebElement element1=driver.findElement(By.xpath("/html/body/section[1]/div/div/section/div[1]/div[2]/ul/li[4]/a"));
String eleText=element1.getText();
System.out.println(eleText);
driver.quit();
}
}
This code opens the browser and lands to the www.selflearning.io page, and then it locates the “Testing” tab on selenium using the findElement() method of SearchContext interface. Once it locates the "Testing" tab element on the web page, we can fetch the text out of it using the getText() method of WebDriver.
Don't miss out!