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 can run multiple test suites using TestNG. We can create two different test suites and can keep the separate test cases in each. We need to create a testing.xml file and specify the test classes of each test suites. Let us see the steps below to start with it:
Once we follow the above steps, then our project directory looks like this:
Let us see both the test class files of these test suites:
TestSuite1:
package suite1;
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.Optional;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
public class TestSuite1 {
WebDriver driver;
@BeforeMethod
void setup()
{
System.setProperty("webdriver.chrome.driver",System.getProperty("user.dir")+"/chromedriver.exe");
driver= new ChromeDriver();
this.driver.get("https://selflearning.io/login");
}
@Parameters({"username","password"})
@Test
void parameterized( @Optional("KcNew") String username, @Optional("admin")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();
}
}
TestSuite2:
package suite2;
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.BeforeMethod;
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
public class TestSuite2 {
WebDriver driver;
@BeforeMethod
void setup()
{
System.setProperty("webdriver.chrome.driver",System.getProperty("user.dir")+"/chromedriver.exe");
driver= new ChromeDriver();
this.driver.get("https://selflearning.io/login");
}
@Parameters({"username","password"})
@Test
void parameterized( @Optional("KcNew") String username, @Optional("admin")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 how out testing.xml should look like to run both the test suites.
Both the suites are included as part of the TestNG suite tag in the testing.xml file, and this lets us execute both the tests by testing.xml itself.
Once we run the testing.xml as TestNG Suite, we can see the execution results of TestNG suite under “Results of running suite” section as below:
Don't miss out!