在没有显示的Linux服务器上运行Chrome WebDriver
我想在 Linux 服务器上使用 selenium2 的 chrome webdriver 运行自动化测试。
我已经使用 Xvfb 将 Firefox 设置为在服务器上运行(请参阅 http: //www.semicomplete.com/blog/geekery/xvfb-firefox.html)并且想用chrome做类似的事情。这可能吗?
I'd like to run automated tests using selenium2's chrome webdriver on a linux server.
I've already set up firefox to run on the server by using Xvfb (See http://www.semicomplete.com/blog/geekery/xvfb-firefox.html) and would like to do something similar with chrome. Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我面临着同样的挑战,用 selenium + chromedriver 设置 Linux 盒子,
这是我的注释:
先决条件:
安装 JRE 来运行 selenium jar
安装 selenium 服务器
从 https://code.google.com/p/selenium 获取 jar 文件/downloads/list)
安装 xvfb(您似乎已经完成了这部分)
为您的 Linux 发行版安装 google-chrome
下载 chrome 驱动程序
您可以从这里获取它:https://sites.google.com/a/ chromium.org/chromedriver/downloads
安装您可能需要的其他 selenium 依赖项(但以上是使 chromedriver 正常工作的最低要求)
运行:
它看起来像这样:
参考:
http://www.yann.com/en/use-xvfb-selenium-and-chrome-to-drive-a-web-browser-in-php-23/08/2012.html< /a>
干杯!
I was facing the same challenge of setting a linux box with selenium + chromedriver,
and here's my notes:
Pre-reqs:
Install JRE to run the selenium jar
Install the selenium server
grab the jar file from https://code.google.com/p/selenium/downloads/list)
Install xvfb (you've seem to have already achieved this part)
Install google-chrome for your linux distribution
Download the chrome driver
You can grab it from here: https://sites.google.com/a/chromium.org/chromedriver/downloads
Install other selenium dependencies that you might need (but the above is the minimum to get chromedriver to work)
To run:
It'll look something like this:
Reference:
http://www.yann.com/en/use-xvfb-selenium-and-chrome-to-drive-a-web-browser-in-php-23/08/2012.html
Cheers!
根据以编程方式将EnvironmentProperty设置为ChromeDriver,您可以执行以下操作:
这是
withEnvironment
的文档According to SetEnvironmentProperty to ChromeDriver programatically you can do the following:
Here is the documentation for
withEnvironment
我还没有找到一种方法可以像使用 FirefoxBinary 那样以编程方式为 ChromeDriver 执行此操作。
我已经提交了一份改进请求,其中附加了一个补丁来允许这样做。您可以在此处查看:http://code.google.com/ p/selenium/issues/detail?id=2673
编辑:
您可以看到下面来自 Stephen 的关于如何使用此更改的回复,现在更改已合并。: https://stackoverflow.com/a/ 16619608/998442
I haven't been able to find a way to do this programmatically for the ChromeDriver like you can with the FirefoxBinary.
I've submitted a improvement request which has a patch attached to allow this. You can see it here: http://code.google.com/p/selenium/issues/detail?id=2673
Edit:
You can see below response from Stephen on how to use this now the change has been merged.: https://stackoverflow.com/a/16619608/998442
我明白你想要做什么,但你可能只是运行硒网格。它是为自动化浏览器测试而设计的。在服务器上运行良好。
https://www.selenium.dev/documentation/en/grid/
I get what you are trying to do, but you probably just run selenium grid. It was made for automated browser testing. Works great on a server.
https://www.selenium.dev/documentation/en/grid/