How to pass parameters from testng.xml into
test case.
package programs;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
public class Parallelexecution {
private WebDriver driver = null;
@BeforeTest
@Parameters({ "BROWSER" })
public void setup(String BROWSER) {
System.out.println("Browser: " + BROWSER);
if (BROWSER.equals("FF")) {
System.out.println("Firefox Browser is selected");
driver = new FirefoxDriver();
} else if (BROWSER.equals("IE")) {
System.out.println("Internet Explorer Browser is selected");
driver = new InternetExplorerDriver();
} else if (BROWSER.equals("HU")) {
System.out.println("Html Unit Browser is selected");
driver = new HtmlUnitDriver();
} else if (BROWSER.equals("CH")) {
System.out.println("Google chrome Browser is selected");
driver = new ChromeDriver();
}
}
@Test
public void testParallel() throws Exception {
driver.get("http://ruchi-myseleniumblog.blogspot.in/2013/12/100-selenium-interview-questions.html");
}
}