How would I initialize the browser if I want to test on multiple browsers using Page Object Model Page Factory?
Currently I have iniatialized the browsers in my Base Class like this.
// initialise driver/browser
public void initDriver() throws MalformedURLException{
if(CONFIG.getProperty("browser").equals("firefox")){
cap = DesiredCapabilities.firefox();
cap.setBrowserName("firefox"); // chrome,iexplore
cap.setPlatform(Platform.ANY);
}else if (CONFIG.getProperty("browser").equals("chrome")){
cap = DesiredCapabilities.chrome(); // no need path of chrome exe
cap.setBrowserName("chrome");
cap.setPlatform(Platform.ANY);
}else if (CONFIG.getProperty("browser").equals("iexplore")){
cap = DesiredCapabilities.internetExplorer(); // no need path of chrome exe
cap.setBrowserName("iexplore");
cap.setPlatform(Platform.WINDOWS);
}
if(driver == null){
driver=new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),cap);
}
String waitTime=CONFIG.getProperty("default_implicitWait");
driver.manage().timeouts().implicitlyWait(Long.parseLong(waitTime), TimeUnit.SECONDS);
}
This however only runs my test my test only on one of the browsers.
This is my testng.xml file
<suite name="Selenium Grid with webdriver" >
<listeners>
<listener class-name="Codes.listener.TestsListenerAdapter" />
</listeners>
<test name="Login test">
<classes>
<class name="Codes.testCases.LoginTest" ></class>
</classes>
</test>
</suite>