如何为Chrome构建远程Webdriver [英] How to build remote Webdriver for Chrome

查看:425
本文介绍了如何为Chrome构建远程Webdriver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to run my Selenium tests against Chrome. When I initialize driver locally:

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

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

Everything works fine (I already put Chrome binary on my PATH) But when I try to launch it remotely:

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

我得到以下错误:


Selenium :: WebDriver :: Error :: UnhandledError:
chromedriver可执行文件的路径必须由webdriver.chrome.driver $ b设置$ b系统属性;有关详情,请参阅
http://code.google.com/p /硒/维基/ ChromeDriver 。最新的
版本可以从
下载 http:// code .google.com / p / chromium / downloads / list
(java.lang.IllegalStateException)

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编写:

I am a bit confused there - how exactly should I set this system property? I found this code written in 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

but my tests are written in Ruby. RubyBindings don't talk about this issue http://code.google.com/p/selenium/wiki/RubyBindings

推荐答案

其实这个错误信息有点不对。您不必 设置系统属性,但需要在远程计算机的PATH(服务器正在运行的位置)使用chromedriver可执行文件。

Actually the error message is slightly wrong. You don't have to set the system property, but the chromedriver executable needs to be available in the PATH on the remote machine (where the server is running).

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

If you want to specify the path as a property, you can do that when you launch the server, e.g.:

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

这篇关于如何为Chrome构建远程Webdriver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆