Snu*_*ker 29 google-chrome webdriver xvfb selenium-webdriver
我想在linux服务器上使用selenium2的chrome webdriver运行自动化测试.
我已经设置了firefox来使用Xvfb在服务器上运行(参见http://www.semicomplete.com/blog/geekery/xvfb-firefox.html),并希望用chrome做类似的事情.这可能吗?
Haf*_*ail 24
我面临着使用selenium + chromedriver设置linux盒子的同样挑战,这是我的笔记:
预请求数:
安装JRE以运行selenium jar
安装selenium服务器
安装xvfb(你似乎已经实现了这个部分)
为您的Linux发行版安装google-chrome
下载Chrome驱动程序您可以从此处获取:https://sites.google.com/a/chromium.org/chromedriver/downloads
安装您可能需要的其他selenium依赖项(但以上是使chromedriver工作的最低要求)
跑步:
Xvfb :1 -screen 5 1024x768x8 &
export DISPLAY=:1.5
java -jar selenium-server-standalone-2.30.0.jar -Dwebdriver.chrome.bin=/path/to/google-chrome -Dwebdriver.chrome.driver=/path/to/chromedriver
2013年3月19日10:07:27 org.openqa.grid.selenium.GridLauncher主要信息:启动独立服务器
将系统属性webdriver.chrome.bin设置为{google-chrome的位置}
将系统属性webdriver.chrome.driver设置为{chromedriver的位置}
10:07:34.258 INFO - RemoteWebDriver实例应该连接到:
http://127.0.0.1:4444/wd/hub10:07:34.259 INFO - Version Jetty/5.1.x 10:07:34.259 INFO - 启动HttpContext [/ selenium-server/driver,/ selenium-server/driver] ...
参考:http: //www.yann.com/en/use-xvfb-selenium-and-chrome-to-drive-a-web-browser-in-php-23/08/2012.html
干杯!
根据SetEnvironmentProperty编程到ChromeDriver,您可以执行以下操作:
service = new ChromeDriverService.Builder()
.usingChromeDriverExecutable(new File("/path/to/chromedriver"))
.usingAnyFreePort()
.withEnvironment(ImmutableMap.of("DISPLAY",":20"))
.build();
Run Code Online (Sandbox Code Playgroud)
我无法像使用FirefoxBinary一样找到以编程方式为ChromeDriver执行此操作的方法.
我已经提交了一个改进请求,其中附有补丁以允许此操作.您可以在此处查看:http://code.google.com/p/selenium/issues/detail?id = 2667
编辑:您可以在下面看到斯蒂芬关于如何使用此更改已被合并的响应:https://stackoverflow.com/a/16619608/998442
| 归档时间: |
|
| 查看次数: |
43543 次 |
| 最近记录: |