Search code examples
javamavenseleniumselenium-webdriverselenium-grid

Load driver executable in Selenium test automation


I am running automation test with Selenium, Maven (my code is written in Java) on a remote machine.

On my virtual machine (Ip: 10.31.142.13) (the one I am running the browsers on): I have folder C:\Selenium with contains selinum server jar file, and IE driver and chrome driver. I run this command:

java -jar selenium-server-standalone-2.44.0.jar -mode hub

On my local machine (the one I run the tests from): I run the test with firefox on virtual machine, and it was successful. But my problem is with IE driver executable file: I don't know how to give the path to folder on my virtual machine. This is my code:

@Test  //this test runs successfully
public void firefoxViewerTest() throws MalformedURLException
{
    System.out.println("Firefox test starting ...");
    DesiredCapabilities capability = DesiredCapabilities.firefox();

    driver = new RemoteWebDriver(new URL("http://10.31.142.13:4444/wd/hub"), capability);        
    driver.manage().deleteAllCookies();
    driverWait = new WebDriverWait(driver, 60);

    baseActions();
    System.out.println("Firefox test pass");
}

@Test
public void ieViewerTest() throws MalformedURLException
{
    System.out.println("IE test starting ...");
    //I want to use path to C:\Selenium on my virtual machine here
    System.setProperty("webdriver.ie.driver", "\\Selenium\\IEDriverServer.exe");
    DesiredCapabilities capability = DesiredCapabilities.internetExplorer();

    driver = new RemoteWebDriver(new URL("http://10.31.142.13:4444/wd/hub"), capability);
    driver.manage().deleteAllCookies();
    driverWait = new WebDriverWait(driver, 60);

    baseActions();
    System.out.println("IE test pass");
}

Any thoughts appreciated. Thanks


Solution

  • Thanks @PriyanshuShekhar for the suggestion. I run the command with -Dwebdriver in front, on the node, and I can run all web browsers IE; FF, Chrome without setting property.

    java -Dwebdriver.ie.driver=C:\Selenium\IEDriverServer.exe -jar selenium-server-standalone-2.44.0.jar -mode hub