package com.testng.examples;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import utility.Helper;
public class ParametersDemo {
WebDriver driver;
@Parameters({"browserName", "url", "searchText"})
@Test
public void parametersDemo(String bn, String url, String text) {
driver = Helper.launchBrowser(bn);
driver.get(url);
driver.findElement(By.name("q")).sendKeys(text);
driver.findElement(By.name("btnG")).click();
}
@AfterTest
public void afterParameterDemo(){
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
driver.close();
}
}
Testng 6:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="My Suite 6" parallel="tests" >
<test name="Parameters Example 1">
<parameter name="browserName" value="ie"></parameter>
<parameter name="url" value="http://google.co.in"></parameter>
<parameter name="searchText" value="Selenium webdriver"></parameter>
<classes>
<class name="com.testng.examples.ParametersDemo"></class>
</classes>
</test> <!-- Parameters Example 1-->
<test name="Parameters Example 2">
<parameter name="browserName" value="chrome"></parameter>
<parameter name="url" value="http://google.co.in"></parameter>
<parameter name="searchText" value="Selenium webdriver"></parameter>
<classes>
<class name="com.testng.examples.ParametersDemo"></class>
</classes>
</test> <!-- Parameters Example 2-->
<test name="Parameters Example 3">
<parameter name="browserName" value="ff"></parameter>
<parameter name="url" value="http://google.co.in"></parameter>
<parameter name="searchText" value="Selenium webdriver"></parameter>
<classes>
<class name="com.testng.examples.ParametersDemo"></class>
</classes>
</test> <!-- Parameters Example 3-->
</suite> <!-- My Suite 6 -->
No comments:
Post a Comment