I'm creating tests(ui tests) on windows 10 machine. They works well, but few days ago my boss told me that we need to run our tests on linux. I'm downloaded linux driver and change it in System.setProperty("webdriver.chrome.driver", "chromedriver");
but after trying to run this test i got java.lang.ExceptionInInitializerError
(it was latest driver with latest browser). After it i changed my code that allow me to run test, but connection to driver is remote. I don't like this way. May be some one of you know which driver will work on linux without code change in driver initialization part?
E.g. windows driver initialization :
private static WebDriver driver = new ChromeDriver();
private static WebDriverWait wait = new WebDriverWait(driver, 30);
@Given("^blah blah$")
public void some_method() {
System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
}
linux driver initialization :
public abstract class InitDrivers{
private static DesiredCapabilities capability = DesiredCapabilities.chrome();
public static WebDriver driver;
static {
try {
driver = new RemoteWebDriver(new URL("http://127.0.0.1:9515"),capability);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
public static WebDriverWait wait = new WebDriverWait(driver, 30);
public class CallDoctorTestStep extends InitDrivers{
@Given("^blah blah$")
public void some_method() throws MalformedURLException{
//System.setProperty("webdriver.chrome.driver","chromedriver.exe");
}
See solution in Selenium NoSuchSession on linux