gpt4 book ai didi

ruby - 如何为 Chrome 构建远程 Webdriver

转载 作者:数据小太阳 更新时间:2023-10-29 06:48:44 26 4
gpt4 key购买 nike

我正在尝试针对 Chrome 运行我的 Selenium 测试。当我在本地初始化驱动程序时:

@driver = Selenium::WebDriver.for( :chrome )

一切正常(我已经将 Chrome 二进制文件放在我的 PATH 中)但是当我尝试远程启动它时:

@driver = Selenium::WebDriver.for(:remote, :url => 'http://' + SELENIUM_HOST + port + webdriver_hub, :desired_capabilities => :chrome)

出现以下错误

Selenium::WebDriver::Error::UnhandledError: The path to the chromedriver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://code.google.com/p/chromium/downloads/list (java.lang.IllegalStateException)

我有点困惑——我到底应该如何设置这个系统属性?我发现这段代码是用 Java 编写的:

DesiredCapabilities caps = DesiredCapabilities.chrome();
caps.setJavascriptEnabled(true);
caps.setCapability("chrome.binary", "/path/to/where/chrome/is/installed/chrome.exe");
System.setProperty("webdriver.chrome.driver","/path/to/where/you/ve/put/chromedriver.exe");
ChromeDriver driver = new ChromeDriver(caps);

但我的测试是用 Ruby 编写的。 RubyBindings 不谈这个问题http://code.google.com/p/selenium/wiki/RubyBindings

最佳答案

其实报错信息有点不对。您没有设置系统属性,但 chromedriver 可执行文件需要在远程机器(运行服务器的地方)的 PATH 中可用。

如果您想将路径指定为属性,您可以在启动服务器时执行此操作,例如:

java -Dwebdriver.chrome.driver=/path/to/driver -jar selenium-server-standalone.jar

关于ruby - 如何为 Chrome 构建远程 Webdriver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6921170/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com