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
Configuring ANT:
Ant is a build tool that helps in taking care of third-party APIs, Classpath of the APIs, the Cleaning process of the previous executable binary file, Compiling, and execution of source code.
Below are the steps to install Ant into your machine.
;C:\Users\apache-ant-1.9.14\bin
Build.xml is an essential file for Ant-based build configurations for cleaning, compiling, and execution of the code.
Sample Build.xml file:
<project name="TestAutomation" basedir=".">
<property name="LIB" value="${basedir}/lib" />
<property name="BIN" value="${basedir}/bin" />
<path id="master-classpath">
<pathelement location="${BIN}" />
<fileset dir="${LIB}" includes="*.jar"/>
</path>
<target name="generateReport">
<delete dir="${basedir}/testng-xslt">
</delete>
<mkdir dir="${basedir}/testng-xslt">
</mkdir>
<xslt in="${basedir}/test-output/testng-results.xml" style="${basedir}/testng-results.xsl" out="${basedir}/testng-xslt/index.html">
<param expression="${basedir}/testng-xslt/" name="testNgXslt.outputDir" />
<param expression="true" name="testNgXslt.sortTestCaseLinks" />
<param expression="FAIL,SKIP,PASS,CONF,BY_CLASS" name="testNgXslt.testDetailsFilter" />
<param expression="true" name="testNgXslt.showRuntimeTotals" />
<classpath refid="master-classpath">
</classpath>
</xslt>
</target>
</project>
TestNG Reports:
As we have discussed that the TestNG is one of the most used automation testing frameworks which works on a range of annotations. Let us see a sample TestNG class that generates the test reports once the TestNG suite completes the execution.
package SeleniumTest.SeleniumTest;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
public class TestNGParameterization {
WebDriver driver;
@BeforeMethod
void setup()
{
driver= new ChromeDriver();
this.driver.get("https://selflearning.io/login");
}
@Test(priority=2)
void test1()
{
}
@Test(priority=1)
void test2()
{
}
@Test(priority=0)
void test3()
{
}
@Parameters({"username","password"})
@Test
void parameterized(String username, String password) throws InterruptedException
{
Thread.sleep(3000);
driver.findElement(By.xpath("//*[@id='admin_login']/div[1]/input")).sendKeys(username);
driver.findElement(By.xpath("//*[@id='admin_login']/div[2]/input")).sendKeys(password);
}
@AfterMethod
void cleanup()
{
driver.quit();
}
}
Let us see the “testing.xml” file to run the tests from xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" >
<test name="Test">
<parameter name="username" value="admin"/>
<parameter name="password" value="adminpassword"/>
<classes>
<class name="SeleniumTest.SeleniumTest.TestNGParameterization"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
Once we run the above sample TestNG class, then we get an output folder for TestNG results under the project directory, as shown below:
Click on the “emailable-report.html” to see the test result report of TestNG:
XSLT Reports:
Let us know how the combination of Ant and TestNG helps us to give the XSLT reports.
Create a TestNG Project:
Let’s see the sample code of a TestNG project:
package SeleniumTest.SeleniumTest;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class XSLTReportingAntTestNG {
WebDriver driver ;
@BeforeMethod
public void startDriver()
{
driver=new ChromeDriver();
this.driver.get("https://selflearning.io/");
}
@Test
public void passTest() {
Assert.assertTrue(true);
}
@Test(priority=0)
public void failTest()
{
Assert.assertTrue(false);
}
}
Install the Ant:
We have seen earlier how to install the Ant. We need this to be installed to create the build for generating the XSLT report. We will use the build.xml file of Ant to generate the report.
Copy XSLT files into your Project:
I have put on my google drive link here. You can download the data from the drive and paste all the files to your project folder.
Now Run the TestNG Project:
Let us now run the TestNG test from eclipse:
Run the build.xml
Now we need to run the build.xml file. A sample of build.xml looks like this:
<project name="TestAutomation" basedir=".">
<property name="LIB" value="${basedir}/lib" />
<property name="BIN" value="${basedir}/bin" />
<path id="master-classpath">
<pathelement location="${BIN}" />
<fileset dir="${LIB}" includes="*.jar"/>
</path>
<target name="generateReport">
<delete dir="${basedir}/testng-xslt">
</delete>
<mkdir dir="${basedir}/testng-xslt">
</mkdir>
<xslt in="${basedir}/test-output/testng-results.xml" style="${basedir}/testng-results.xsl" out="${basedir}/testng-xslt/index.html">
<param expression="${basedir}/testng-xslt/" name="testNgXslt.outputDir" />
<param expression="true" name="testNgXslt.sortTestCaseLinks" />
<param expression="FAIL,SKIP,PASS,CONF,BY_CLASS" name="testNgXslt.testDetailsFilter" />
<param expression="true" name="testNgXslt.showRuntimeTotals" />
<classpath refid="master-classpath">
</classpath>
</xslt>
</target>
</project>
Now run the build.xml as “Ant Build”.
Once build gets successful, it will generate the output files under “testing-XSLT" folder for the XSLT reports as shown below:
Click in the index.html file in the "testing-XSLT" folder. XSLT report gets displayed in the web browser.
Don't miss out!