Need loop within the java class using TestNG - java

I already wrote a for loop if I have one method, but what if I have multiple method in my TestNG scripts.
I was able to make it work if I put a variable within the public class, but I need this to run hostnum 2 through hostnum 50. So I need a for loop within the class while using TESTNG so therefore can't use public static main.
here is my code please advise me what I can do. I'm a noob :(
package firsttestngpackage;
import org.openqa.selenium.*;
import org.testng.annotations.*;
import org.openqa.selenium.chrome.ChromeDriver;
public class Test5 {
WebDriver driver;
//I NEED A FOR LOOP WITHIN THIS CLASS!!
//THIS IS NOT WORKING
/* for {
}
int hostnum = x;*/
//THIS IS NOT WORKING
/* for (int x = 1; x <= 2; x++){
int hostnum = x;
}*/
//THIS IS WORKING BUT NO LOOP :(
int hostnum = 2;
#Test(priority = 1, enabled = true)
public void method1() throws Exception {
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
driver = new ChromeDriver();
driver.get("https://www.google.com");
}
#Test(priority = 2, enabled = true)
public void method2() throws Exception {
driver.findElement(By.id("lst-ib")).sendKeys("host" + hostnum + "_CR");
}
}

Use Parameters from your testng.xml and pass them to your tests.
Your testng.xml:
<suite name="TestSuite">
<test name="Test2">
<parameter name="host" value="host2_CR" />
<classes>
<class name="SampleTest" />
</classes>
</test> <!-- Test2 -->
<test name="Test3">
<parameter name="host" value="host3_CR" />
<classes>
<class name="SampleTest" />
</classes>
</test> <!-- Test3 -->
<!-- ... -->
<test name="Test50">
<parameter name="host" value="host50_CR" />
<classes>
<class name="SampleTest" />
</classes>
</test> <!-- Test50 -->
</suite> <!-- TestSuite -->
Your class:
public class SampleTest {
WebDriver driver;
String host;
#Parameters({"host"})
#BeforeTest
public void beforeTest(String host) {
this.host = host;
}
#Test(priority = 1, enabled = true)
public void method1() throws Exception {
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
driver = new ChromeDriver();
driver.get("https://www.google.com");
}
#Test(priority = 2, enabled = true)
public void method2() throws Exception {
driver.findElement(By.id("lst-ib")).sendKeys(this.host);
}
}

Related

Parallel execution using TestNg Selenium in a POM framework overwriting the data object class

I am trying to run two test classes in parallel both are using data providers pointing to different excel sheets. Sequentially it runs fine, but while running it in parallel it seems like the test object class which is holding all the test data is getting overwritten. Below is the data provider
Class 1
#DataProvider(name = "tradeData" )
public Object[][] createMessage() {
return ExcelUtils
.getDataFromExcelSheet("TestSheet1", LOADTESTDATAPROVIDER);
}}
Class 2
#DataProvider(name = "tradeData")
public Object[][] createMessage() {
return ExcelUtils
.getDataFromExcelSheet("TestSheet2", LOADTESTDATAPROVIDER);
}
The data is being returned correctly from the excel but it seems like it is getting overwritten when placed into the object class. The data object class is being initialized from both test classes something like this
#Test(dataProvider = "tradeData")
public void connectAndPushMessage(String sellerName,
String buyerName,
String SIN){
testMessage tMessage = new testMessage();
tMessage.setSellerName(sellerName);
tMessage.setBuyerName(buyerName);
tMessage.setSIN(SIN);
}
Below is the testng.xml that I have used.
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Parallel Testing" parallel="classes" thread-count="2">
<test name="Test run 1">
<classes>
<class name="test.xxx.performance.InjectTrades_TestRun1"/>
<class name="test.xxx.performance.InjectTrades_TestRun2"/>
</classes>
</test>
</suite>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Parallel Testing" parallel="tests" thread-count="2">
<test name="Test run 1">
<classes>
<class name="test.xxx.performance.InjectTrades_TestRun1"/>
</classes>
</test>
<test name="test run 2">
<classes>
<class name="test.xxx.performance.InjectTrades_TestRun2"/>
</classes>
</test>
I am getting the same result from both xmls so rather six distinct messages being created/pushed into the system(based on two excel sheets) the code is pushing three distinct messages repeated twice. I was/am under the impression that testNg should have take care of this as both classes/tests are running as separate threads.
EDIT
Below is the snippet of the Test object class. All attributes are declared private
public class testMessage{
private String currentBusinessDate;
private String sellerName = "";
private String buyerName= "";
private String sin= "";
....
public testMessage() {
cTradeID = "T" + CommonUtils.randomNumber(12);
sRef = CommonUtils.randomNumber(12);
requestId = "1" + CommonUtils.randomNumber(5);
settlementRequestStateCode = "New";
currencyTypeCode = "USD";
}
public String getCurrentBusinessDate() {
return currentBusinessDate;
}
public void setCurrentBusinessDate(String currentBusinessDate) {
this.currentBusinessDate = currentBusinessDate;
}
public String getsellerName () {
return currentBusinessDate;
}
public void setsellerName (String currentBusinessDate) {
this.currentBusinessDate = currentBusinessDate;
}
public String getBuyerName () {
return currentBusinessDate;
}
public void setBuyerName (String currentBusinessDate) {
this.currentBusinessDate = currentBusinessDate;
}
....
Used TestNG version is not mentioned, also ExcelUtils.getDataFromExcelSheet implementation is not shared, but both these 2 things might be related to such unexpected behavior.
I'm going to share my experiment result in order to confirm, that there is no issue with the TestNG parallelization itself, at least for TestNG 7.5.
Test Class 1
class T1 {
#Test(dataProvider = "tradeData")
public void connectAndPushMessage(String arg) {
System.out.println(arg);
}
#DataProvider(name = "tradeData")
public Object[][] createMessage() {
return new Object[]{
{ "T1.createMessage-data-1" },
{ "T1.createMessage-data-2" },
{ "T1.createMessage-data-3" },
};
}
}
Test Class 2
class T2 {
#Test(dataProvider = "tradeData")
public void connectAndPushMessage(String arg) {
System.out.println(arg);
}
#DataProvider(name = "tradeData")
public Object[][] createMessage() {
return new Object[]{
{ "T2.createMessage-data-1" },
{ "T2.createMessage-data-2" },
{ "T2.createMessage-data-3" },
};
}
}
testng.xml
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Parallel Testing" parallel="tests" thread-count="2">
<test name="Test run 1">
<classes>
<class name="samples.T1"/>
</classes>
</test>
<test name="test run 2">
<classes>
<class name="samples.T2"/>
</classes>
</test>
</suite>
Output:
T1.createMessage-data-1
T2.createMessage-data-1
T2.createMessage-data-2
T1.createMessage-data-2
T2.createMessage-data-3
T1.createMessage-data-3
The same for
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Parallel Testing" parallel="classes" thread-count="2">
<test name="Test run 1">
<classes>
<class name="samples.T1"/>
<class name="samples.T2"/>
</classes>
</test>
</suite>
Try to recheck this with TestNG 7.5, and look at your ExcelUtils.getDataFromExcelSheet method implementation, it should be thread-safe.

#AfterTest TestNG annotation is not called

I'm doing some tests using Java + TestNG, but I noticed that the tests are not executing the #AfterTest method. The browser remains open when the other tests are running (when it runs the first test, CreateNewUserWithValidData(), this one doesn't call the #AfterTest method, causing that the other tests fail). I need that every test call the #AfterTest method.
My testng.xml file has the following structure:
<suite name="Sample Tests" verbose="1" >
<listeners>
<listener class-name="Utilities.Listeners.TestListener"></listener>
<listener class-name="Utilities.Listeners.AnnotationTransformer"></listener>
</listeners>
<test name="Regression" >
<classes>
<class name="Tests.AutomationPracticesTests">
<methods>
<include name="CreateNewUserWithValidData" />
<include name="LoginWithAValidUser" />
<include name="LoginWithAnInvalidUser" />
</methods>
</class>
</classes>
</test>
</suite>
My BaseTest class looks like this.-
public class BaseTest {
protected String baseURL;
protected WebDriver driver;
protected WebDriverWait wait;
protected APAuthenticationPage apAuthenticationPage;
protected APCreateAccountPage apCreateAccountPage;
protected APHomePage apHomePage;
protected APMyAccountPage apMyAccountPage;
protected APShoppingCartAddressesPage apShoppingCartAddressesPage;
protected APShoppingCartOrderConfirmationPage apShoppingCartOrderConfirmationPage;
protected APShoppingCartOrderSummaryBankwirePage apShoppingCartOrderSummaryBankwirePage;
protected APShoppingCartPaymentMethodPage apShoppingCartPaymentMethodPage;
protected APShoppingCartShippingPage apShoppingCartShippingPage;
protected APShoppingCartSummaryPage apShoppingCartSummaryPage;
public WebDriver getDriver() {
return driver;
}
#BeforeTest(alwaysRun = true)
public void setUp() {
Log.info("I am in Before Method! Test is starting!");
driver = WebDriverFactory.getDriver(BrowserType.Chrome);
wait = new WebDriverWait(driver, 10);
driver.manage().window().maximize();
}
#BeforeMethod
public void initSetup() {
String propertiesFile = "data.properties";
PropertyReader propertyReader = new PropertyReader();
apAuthenticationPage = new APAuthenticationPage(driver);
apCreateAccountPage = new APCreateAccountPage(driver);
apHomePage = new APHomePage(driver);
apMyAccountPage = new APMyAccountPage(driver);
apShoppingCartAddressesPage = new APShoppingCartAddressesPage(driver);
apShoppingCartOrderConfirmationPage = new APShoppingCartOrderConfirmationPage(driver);
apShoppingCartOrderSummaryBankwirePage = new APShoppingCartOrderSummaryBankwirePage(driver);
apShoppingCartPaymentMethodPage = new APShoppingCartPaymentMethodPage(driver);
apShoppingCartShippingPage = new APShoppingCartShippingPage(driver);
apShoppingCartSummaryPage = new APShoppingCartSummaryPage(driver);
baseURL = propertyReader.getProperty(propertiesFile, "AUTOMATION_PRACTICE_URL");
}
#AfterTest(alwaysRun = true)
public void tearDown() {
Log.info("I am in After Method! Test is ending!");
driver.close();
driver.quit();
}
}
And my tests are the following ones.-
public class AutomationPracticesTests extends BaseTest {
// Properties
private String emailAddress, password;
// Tests
#Test(description = "It creates a new user in the store",
priority = 1)
public void CreateNewUserWithValidData(Method method) {
startTest(method.getName(), "It creates a new user in the store");
emailAddress = Mocks.personalData().get(0).getEmail();
password = Mocks.personalData().get(0).getPassword();
apHomePage.goTo(baseURL);
apHomePage.clickOnSignInButton();
apAuthenticationPage.fillCreateAccountForm(emailAddress);
apAuthenticationPage.clickOnCreateAccountButton();
apCreateAccountPage.fillRegisterForm(Mocks.personalData());
apCreateAccountPage.clickOnRegisterButton();
Assert.assertTrue(apMyAccountPage.isLoaded());
}
#Test(description = "It logins successfully in the store with a valid user",
priority = 2)
public void LoginWithAValidUser(Method method) {
apHomePage.goTo(baseURL);
apHomePage.clickOnSignInButton();
apAuthenticationPage.fillSignInForm(emailAddress, password);
apAuthenticationPage.clickOnSignInButton();
Assert.assertTrue(apMyAccountPage.isLoaded());
}
#Test(description = "It throws an error when the user attempts to login with an invalid user",
priority = 3)
public void LoginWithAnInvalidUser(Method method) {
apHomePage.goTo(baseURL);
apHomePage.clickOnSignInButton();
apAuthenticationPage.fillSignInForm(Mocks.invalidPersonalData().getEmail(), Mocks.invalidPersonalData().getPassword());
apAuthenticationPage.clickOnSignInButton();
Assert.assertEquals("Authentication failed.", apAuthenticationPage.IsErrorBannerDisplayed());
}
}
I'm suspecting that's something related to the testng.xml file (but, tbh, there are some things that I don't understand about how to configure correctly this file).
I'll appreciate any help to solve my problem. Thanks in advance!
It's not a bug. It work as expected.
BeforeTest
BeforeMethod
Method 1: CreateNewUserWithValidData
BeforeMethod
Method 2: LoginWithAValidUser
BeforeMethod
Method 3: LoginWithAnInvalidUser
AfterTest
If you want to close the browser before method 2, then you need to change AfterTest --> AfterMethod, and initialize browser in BeforeMethod
If you just want to change the testng.xml
<test name="test1">
<classes>
<class name="Tests.AutomationPracticesTests">
<methods>
<include name="CreateNewUserWithValidData"/>
</methods>
</class>
</classes>
</test>
<test name="test2">
<classes>
<class name="Tests.AutomationPracticesTests">
<methods>
<include name="LoginWithAValidUser"/>
</methods>
</class>
</classes>
</test>
<test name="test3">
<classes>
<class name="Tests.AutomationPracticesTests">
<methods>
<include name="LoginWithAnInvalidUser"/>
</methods>
</class>
</classes>
</test>

When Running Selenium with TestnG I get FAILED CONFIGURATION: BeforeClass setUp?

#BeforeClass I get null null errors I believe it's something with my before class.What about optional do you need them? FAILED CONFIGURATION: #BeforeClass setUp(null, null) I tried to add different maven dependiencies maybe its because of selenium version its still wont work.
public class Practice {
WebDriver driver;
//Check this ont out
#BeforeClass(alwaysRun = true)
#Parameters({ "browser", "url" })
public void setUp(#Optional("browser") String browser, #Optional("url") String url) {
BaseTest base = new BaseTest(browser, url);
driver = base.getDriver();
}
#Test
public void Check() {
try {
System.out.println("Passed Test case...");
Assert.assertTrue(driver.getTitle().contentEquals("Google"));
} catch (Exception ee) {
System.out.println("NOOOOO ");
ee.printStackTrace();
Assert.assertEquals("noooo " + ee, "iT SHOULD NOT fAIL");
}
}
public class Selen {
private WebDriver driver;
private String browser;
private String url;
public Selen(String browser, String url) {
this.browser = browser;
this.url = url;
if (browser.equalsIgnoreCase("firefox")) {
System.setProperty("webdriver.firefox.marionette",
"C:\\Users\\geckodriver.exe");
final FirefoxProfile firefox = new FirefoxProfile();
driver = new FirefoxDriver();
driver.get(url);
}
else if (browser.equalsIgnoreCase("chrome")) {
// set path to chromedriver.exe
System.setProperty("webdriver.chrome.driver", "C:\\Drivers\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("--enable-automation", "test-type=browser", "--disable-plugins", "--disable-infobars",
"--disable-notifications", "start-maximized");
driver = new ChromeDriver(options);
driver.get(url);
}
else if (browser.equalsIgnoreCase("Edge")) {
// set path to Edge.exe
System.setProperty("webdriver.edge.driver", ".\\MicrosoftWebDriver.exe");
driver = new EdgeDriver();
driver.get(url);
} else {
}
}
public String getBrowser() {
return this.browser;
}
public String getBaseUrl() {
return this.url;
}
public WebDriver getDriver() {
return this.driver;
}
#AfterClass
public void tearDown(WebDriver driver) {
quitDriver(driver);
}
protected static void quitDriver(WebDriver driver) {
try {
if (driver != null) {
driver.quit();
}
} catch (Exception ee) {
System.out.println("Failed: " + ee);
;
}
}
**Failed Configuration**
[RemoteTestNG] detected TestNG version 6.14.3
Check() test case...
There was a problem:
java.lang.NullPointerException
at com.seleniumae.exercise.Practice.Check(Practice.java:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:583)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:719)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:989)
TeNg.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
<test thread-count="5" name="Test">
<parameter name="browser" value= "Chrome" />
<parameter name="url" value="https://www.google.com/"/>
<classes>
<class name="com.seleniumae.exercise.Practice"/>
<class name="com.seleniumae.exercise.Practice1"/>
<class name="com.seleniumae.exercise.Practice2.java"/>
</classes>
</test> <!-- Test -->
<test thread-count="5" name="Test">
<parameter name="browser" value ="Firefox" />
<parameter name="url" value="https://www.google.com/"/>
<classes>
<class name="com.seleniumae.exercise.Practice"/>
<class name="com.seleniumae.exercise.Practice1"/>
<class name="com.seleniumae.exercise.Practice2"/>
</classes>
</test> <!-- Test -->
<test thread-count="5" name="Test">
<parameter name="browser" value="InternetExplore" />
<parameter name="url" value="https://www.google.com/"/>
<classes>
<class name="com.seleniumae.exercise.Practice"/>
<class name="com.seleniumae.exercise.Practice1"/>
<class name="com.seleniumae.exercise.Practice2.java"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
The issue could be about parameters with browser taking one parameter like chrome when it should be another parameter.
Syntax to define #Optional annotation :
public void setUp(#Optional("browser_name") String browser, #Optional("site_name") String url)
And you are implementing in following way without using #Optional("value")
public void setUp(#Optional String browser, #Optional String url) throws MalformedURLException {
TestNG.xml - please write parameters like below
<suite name="Suite">
<test thread-count="5" name="Test">
<parameter name="url" value="https://www.google.com/"/>
<parameter name="browser" value= "Chrome" />
Note - TestNG provides you flexibility of declaring parameters as optional. When we declare a parameter as optional and If defined parameter is not found in your testng.xml file, The test method will receive the default value which is specified inside the #Optional annotation.

Second class of testing.xml doesn't execute

I have created 2 separate classes to test a webpage. But, unfortunately when I add them both to the testing.xml, only one of them execute and the other doesn't. The browsers open in parallel even after setting them to preserve-order="true" parallel="false" in the XML. I'm confused as to where I'm doing it wrong.
This is my XML file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" preserve-order="true" parallel="false">
<test name="Test">
<classes>
<class name="TestServiceNow.loginOne"/>
<class name="TestServiceNow.loginTwo"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
loginOne is as follows:
package TestServiceNow;
import org.testng.annotations.Test;
import ServiceNow.login;
public class loginOne extends loginTest{
#Test
public void test_Login(){
//Create Login Page object
objLogin = new login(driver);
//login to application
objLogin.loginGurukula("admin", "admin");
}
}
loginTwo is as follows:
import org.testng.annotations.Test;
import ServiceNow.login;
public class loginTwo extends loginTest{
#Test
public void test_Login_Fail(){
//Create Login Page object
objLogin = new login(driver);
//login to application
objLogin.loginGurukula("admin", "admin1");
}
}
The base class is as follows:
public class loginTest {
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
File file = new File("C:/Users/gattu_000/Documents/selenium-java-3.0.0-beta2/chromedriver_win32/chromedriver.exe");
WebDriver driver;
login objLogin;
#BeforeClass
public void a() {
driver = new ChromeDriver(capabilities);
capabilities.setCapability("marionette", true);
System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
System.out.println("Before class called");
}
#BeforeTest
public void setup(){
System.out.println("Before test called");
driver.get("http://localhost:8080/#/login");
}
#AfterTest
public void close() {
System.out.println("After test called");
}
#AfterClass
public void b() {
System.out.println("After class called");
driver.close();
}
}
The results look like
After the Edit
You are extending loginTest by both loginOne and loginTwo. But in loginTest you initialized your driver. That's why two browser are opening. To get around this issue, you can initialize your driver inside a setup method like #BeforeTest or #BeforeSuite. As an example here's a code snippet -
#BeforeSuite
public void a() {
driver = new ChromeDriver(capabilities);
System.out.println("Before suite called");
}
Do other things as usual like before except the initialization part.
Edit
I missed something. You are closing your driver at the after test method. To run your tests properly remove the driver.close() from your after test method and place it to aftereSuite section.
The XML is supposed to be like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" preserve-order="true">
<test name="Test">
<classes>
<class name="TestServiceNow.loginOne"/>
</classes>
</test> <!-- Test -->
<test name="Test1">
<classes>
<class name="TestServiceNow.loginTwo"/>
</classes>
</test>
</suite> <!-- Suite -->
To launch the browser twice, we need to have 2 separate tests. (Possibly, this may be one of the solutions out of many)
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Selenium Test Suite">
<test name="Selenium Test Suite">
<classes>
<class name="packagename.classname1"/>
<class name="packagename.classname1"/>
</classes>
</test>
</suite>
Which is proper. If you are getting null point don't use driver in all the class. because of that only you are getting null pointer i guess.

Run junit test with on different browsers

I want to run tests on different browsers, using junit, selenium, i have this code:
#Test //Test1
public void logInFaildTest() {
GridTest gridTest = new GridTest();
WebDriver webDriver = gridTest.getWebDriver();//get driver
LoginPage logIn = new LoginPage(webDriver, url);
String userName = "user";
String pass="pass";
......................................
webDriver.close();
}
#Test //Test2 change
public void logInFaildTest(WebDriver webDriver ) {
LoginPage logIn = new LoginPage(webDriver, url);
String userName = "user";
String pass="pass";
......................................
webDriver.close();
}
#Test //Test3
public void loginSucsecc(WebDriver webDriver )
{
WebDriver webDriver = gridTest.getWebDriver();
LoginPage logIn = new LoginPage(webDriver, url);
......................................
webDriver.quit();
assertEquals(expected, actual);
}
In test 1 i create an instance of webdriver inside the test method, in test 2 and 3 i want to get the test driver as parameter and execute the test with the specific webdriver, how can i run test case that can run each function with different web driver(one on firefox other on chrome...).
solution To send test function parameters, must set class as #RunWith(Parameterized.class).
Another solve is to read properties file in each test method, and run the test as the properties.
best way to do is , group the tests which you want to run specific browser.
Send browser parameter from testNg to run in specific browser.
Test Class:
#Parameters({ "browser" })
#Test(groups="IE")
public void logInFaildTest(String browser) {
GridTest gridTest = new GridTest();
WebDriver webDriver = gridTest.getWebDriver();//get driver
LoginPage logIn = new LoginPage(webDriver, url);
String userName = "user";
String pass="pass";
......................................
webDriver.close();
}
#Parameters({ "browser" })
#Test(groups="IE")
public void logInFaildTest(String browser ) {
LoginPage logIn = new LoginPage(webDriver, url);
String userName = "user";
String pass="pass";
......................................
webDriver.close();
}
#Parameters({ "browser" })
#Test(groups="Chrome")
public void loginSucsecc(String browser )
{
WebDriver webDriver = gridTest.getWebDriver();
LoginPage logIn = new LoginPage(webDriver, url);
......................................
webDriver.quit();
assertEquals(expected, actual);
}
TestNg:
<test name="Testing Parameterization">
<parameter name="browser" value="IE"/>
<parameter name="username" value="testuser"/>
<parameter name="password" value="testpassword"/>
<groups>
<run>
<include name="IE"/>
</run>
</groups>
<classes>
<class name="com.parameterization.TestParameters" />
</classes>
</test>
<test name="Testing Parameterization">
<parameter name="browser" value="Firefox"/>
<parameter name="username" value="testuser"/>
<parameter name="password" value="testpassword"/>
<groups>
<run>
<include name="chrome"/>
</run>
</groups>
<classes>
<class name="com.parameterization.TestParameters" />
</classes>
</test>

Categories