硒网格2铬

时间:2014-08-25 09:58:17

标签: google-chrome selenium-webdriver

我在Windows 7中使用selenium-2.42.2,我启动了一个集线器并键入" java -jar selenium-server-standalone.jar -role node -nodeConfig nodeconfig.json -Dwebdriver.chrome.driver= D:\selenium\chromedriver.exe" 在终端中,以下是junit 4测试用例:

    public void setUp() throws Exception {

    driver = new ChromeDriver();
    baseUrl = "http://127.0.0.1:8443/";
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
  }

  @Test
  public void testWebdriver() throws Exception {
    driver.get(baseUrl + "/customizedfolder/main.html");
    for (int second = 0;; second++) {
        if (second >= 60) fail("timeout");
        try { if (isElementPresent(By.xpath("//div[@id='f21TemFolder']/div/span"))) break; } catch (Exception e) {}
        Thread.sleep(1000);
    }

    driver.findElement(By.xpath("//div[@id='f21TemFolder']/div/span")).click();    

  }

nodeconfig.jso是:

{
 "capabilities": [ 
{ "browserName": "*firefox", "seleniumProtocol":"Selenium","platform": "LINUX", "maxInstances": 3 },
{"browserName": "*chrome", "seleniumProtocol":"WebDriver","platform": "LINUX", "maxInstances": 3 } 
], 
"configuration": { "nodeTimeout":120, "port":5555, "hubPort":4444, "hubHost":"localhost", "nodePolling":2000, "registerCycle":10000, "register":true, "cleanUpCycle":2000, "timeout":30000, "maxSession":1, }
 }

但它无法打开chrome,错误是:驱动程序可执行文件的路径必须由webdriver.chrome.driver系统属性设置....

我还在系统属性中设置webdriver.chrome.driver,但也失败了。

chrome版本为:36.0.1985.143 m,chr​​ome驱动程序版本为:2.10

如何在硒网格2中使用铬?

1 个答案:

答案 0 :(得分:2)

好吧,我认为-Dwebdriver arg中的问题,你应该写-Dwebdriver.chrome.driver 像这样... ...

java -jar selenium-server-standalone.jar -role node -nodeConfig nodeconfig.json  -Dwebdriver.chrome.driver=D:\selenium\chromedriver.exe