/**
* First try to create phantomJS. If that fails, try Chrome.
*/
public RemoteWebDriver newBrowser() {
RemoteWebDriver driver;
switch (getBrowserType()) {
case FIREFOX:
driver = new FirefoxDriver();
break;
case INTERNET_EXPLORER:
driver = new InternetExplorerDriver();
break;
case CHROME:
driver = new ChromeDriver();
break;
case PHANTOMJS:
driver = new PhantomJSDriver();
break;
default:
throw new IllegalStateException("Unsupported browsertype " + getBrowserType());
}
driver.manage()
.timeouts()
.implicitlyWait(5, TimeUnit.SECONDS)
.pageLoadTimeout(30, TimeUnit.SECONDS)
.setScriptTimeout(30, TimeUnit.SECONDS);
driver.manage()
.deleteAllCookies();
return driver;
}