如何在 Jenkins 托管的 Grid 上使用 Chromedriver 设置 Selenium [英] How to set up Selenium with Chromedriver on Jenkins-hosted Grid

查看:18
本文介绍了如何在 Jenkins 托管的 Grid 上使用 Chromedriver 设置 Selenium的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是用 Selenium 迈出了第一步.我成功设置了一个测试(Firefox 驱动程序),在我的 Jenkins 上的 Selenium 网格上运行(使用 Jenkins-Selenium-Grid 插件).我还在运行 Jenkins 的机器(Server2003 64 位)上安装了 Chromdriver 插件和 Chrome 本身.为所有用户安装了 Chrome(在 C:Program Files (x86)GoogleChromeApplicationchrome.exe 中).问题是:一旦我尝试使用我得到的 Chromedriver

I just make my frist steps with Selenium. I successfully set up a test (Firefox driver), running on Selenium grid on my Jenkins (using Jenkins-Selenium-Grid plugin). I also installed Chromdriver plugin and Chrome itself on the machine (Server2003 64bit) running Jenkins. Chrome is installed for all users (in C:Program Files (x86)GoogleChromeApplicationchrome.exe). The Problem is: as soon i try to use the Chromedriver i get

UnreachableBrowserException: Could not start a new session. Possible causes are invalid     address of the remote server or browser start-up failure.

既然 Firefox 测试运行良好,那一定是浏览器启动"的问题?!所以第一个问题是:Chromdriver 假定的 chrome 二进制文件的默认位置是什么?第二个问题:如何解决这个问题?是否有要设置的环境属性?或者我可以简单地将 PATH 设置为 chrome.exe 的位置.

Since the Firefox test runs fine it must be a problem with "browser start"?! So the first question is: What is the default location for chrome binary that Chromdriver assumes? Second Question: How to fix this? Is there an Einvironment Property to set? Or could i simply set PATH to chrome.exe' location.

更新:我挖了一下,我想我遇到了 这个那个.这个问题有什么解决方法吗?

UPDATE: i dug around a bit, ithink i ran into this or that. is the any workaround for this issues?

推荐答案

我自己也经历了同样的过程.

Just went through the same process myself.

使用 Selenium 插件,您可以设置 selenium 网格.
使用 Chromedriver Plugin 您可以自动安装 chrome 驱动程序.
使用 Selenium Axis Plugin 您可以创建矩阵作业.

Using Selenium Plugin you can set up the selenium grid.
Using Chromedriver Plugin you can have chrome driver automatically installed.
Using Selenium Axis Plugin you can create matrix jobs.

首次安装问题安装 Chromedriver 插件后,可能需要几分钟才能下载并在自动安装后准备就绪.可能是从服务器在完全安装主服务器之前尝试安装 chromedriver,因此无法查找下载位置.重新启动从站将导致它再次尝试并在从站上安装 chromedriver.

First time installation issue After installing the Chromedriver plugin it can take a few minutes to download and be ready after it is automatically installed. It can be that the slaves try and install the chromedriver before master is fully installed and so fail to lookup the download location. Restarting the slaves will cause it to try again and install the chromedriver on the slaves.

在每个从属和主控上,您最终应该得到一个 $JENKINS_HOME oolschromedriverchromedrive.exe,您可以在 Chrome[driver] 二进制文件的 Jenkins Selenium 插件配置中参考它路径为 toolschromedrivechromedriver.exe 和 Jenkins 将为您添加特定从站的 $JENKINS_HOME.

On each slave and the master you should finally end up with a $JENKINS_HOME oolschromedriverchromedrive.exe which you can refer to in the Jenkins Selenium plugin configuration for Chrome[driver] binary path as toolschromedrivechromedriver.exe and Jenkins will prepend the slave specific $JENKINS_HOME for you.

将 Chrome 安装到默认位置,结果是 C:Program Files (x86)GoogleChromeApplicationchrome.exe 与描述的相同.

Installed Chrome to the default location which turned out to be C:Program Files (x86)GoogleChromeApplicationchrome.exe same as described.

此时我可以成功运行测试作业,而不会出现您显示的错误.

At this point I could run a test job succesfully without the error you have shown.

DesiredCapabilities capability = DesiredCapabilities.chrome();
WebDriver driver = new RemoteWebDriver(new URL("http://Jenkins.ip.here:4444/wd/hub"), capability);
driver.get(siteBase.toString());
String page = driver.getPageSource();

还有一些需要考虑的事情

So some other things to consider

  • 更改了 jenkins selenium 配置后,您是否重新启动了 selenium 服务,配置更改后它似乎停止了它们.配置是否指定了实例.
  • 如果是安装位置问题,您可以使用

  • having changed jenkins selenium config, did you restart selenium service, after config change it appears to stop them. Does the config have instances specified.
  • if it was an install location issue, you might be able to change the install location options in the test cases using

ChromeOptions options = new ChromeOptions();
options.setBinary("/path/to/other/chrome/binary");

这篇关于如何在 Jenkins 托管的 Grid 上使用 Chromedriver 设置 Selenium的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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