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
TestNG has a variety of features that distinguish it from other testing tools. One of those features is Parameterization. We can control the behaviour of the annotated method by providing the parameters with annotations.
Let us discuss how to pass the parameters with different parameters of the changing behaviour of the annotated method.
Priority:
The priority of a test method can be set by passing a priority parameter along with the numerical value of the priority. Let us see how to set the priority of an annotated method:
@Test(priority=2)
void test1()
{
}
@Test(priority=1)
void test2()
{
}
@Test(priority=0)
void test3()
{
}
Once we run above the TestNG setup, then the order of execution depends on the priority given to each annotated method. The lowest priority value to an annotation means the highest priority for that annotated method.
So here test3 gets executed first, then test2 and at last test1 gets executed. Let us see the results of the running TestNG class:
We can see the order where the order of execution is test3, test2, and test1. So, priority is a handy parameter to control the execution order of test methods.
@Parameters annotation:
Let us see the below code where we are passing on the parameters into the test method, and the respective values of each parameter are set inside the testing.xml file.
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");
}
@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();
}
}
Here “username” and “password” parameter values are defined inside the testing.xml file as shown below:
<?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 -->
Don't miss out!