문제

I've hub and node running and I'm trying to run test on node for chrome browser, but it's failing with error: The path to the driver executable must be set by the webdriver.chrome.driver system property;

But I've set it. Following is the code which I'm using:

package seleniumgridpackage;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import org.openqa.selenium.remote.RemoteWebDriver;


public class SeleniumGridTest {
    WebDriver driver;
    String baseUrl = "http://www.google.com";
    String expectedTitle = "Google";

    @BeforeTest
    public void setUp() throws MalformedURLException {
        File file = new File("C://Drivers//chromedriver.exe");
        //File file = new File("C://Drivers//IEDriverServer.exe");
        System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());

        DesiredCapabilities cap = DesiredCapabilities.chrome();
        cap.setBrowserName("chrome");
        cap.setPlatform(Platform.VISTA);
        driver  = new RemoteWebDriver(new URL("http://x.x.x.x:5566/wd/hub"), cap);

    }

    @Test
    public void test(){
        driver.get(baseUrl);
        Assert.assertEquals(driver.getTitle(), expectedTitle);
    }

    @AfterTest
    public void tearDown(){
        driver.quit();
    }
}

Note: I've put chromedriver.exe in C://Drivers folder of both node and hub. Sams happens when I try with IE

Please help me understand what I'm doing wrong.

도움이 되었습니까?

해결책

Everything is in how do you start the node. So First, do the usual:

java -jar -jar selenium-server-standalone-2.20.0.jar -role hub

Then start the node like this:

java -jar lib/selenium-server-standalone-2.20.0.jar -role webdriver -hub http://localhost:4444/grid/register -browser browserName="chrome",version=ANY,platform=WINDOWS,maxInstances=5 -Dwebdriver.chrome.driver=lib\chromedriver.exe 

more specifically: You have to start up the NODE with parameter browser and add -D parameter specifying the full path to the chromedriver

My huge thanks goes to John Naegle who answered similar question here on SO regarding the internet explorer - see here

다른 팁

I tried various combinations and finally found that the property needs be set at runtime.

To Start the node use : This will work for firefox

java -jar sel2.40.jar -role node -hub http://locahost:4443/grid/register -port 5556

To Start the node for IE, we need to specify the webdriver.ie.driver system property while starting the node :

java -Dwebdriver.ie.driver="D:\IEDriverServer.exe" -jar sel2.40.jar -role node -hub http://locahost:4443/grid/register -port 5556
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top