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

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

问题描述

我刚开始与Selenium合作.我成功设置了一个测试(Firefox驱动程序),该测试在Jenkins的Selenium网格上运行(使用Jenkins-Selenium-Grid插件).我还在运行Jenkins的计算机(Server2003 64位)上安装了Chromdriver插件和Chrome本身. 已为所有用户安装Chrome(位于C:\ Program Files(x86)\ Google \ Chrome \ Application \ chrome.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)\Google\Chrome\Application\chrome.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插件,您可以设置硒网格. br> 使用 Chromedriver插件,您可以自动安装chrome驱动程序.
使用 Selenium Axis插件,您可以创建矩阵作业.

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\tools\chromedriver\chromedrive.exe,您可以在Chrome [驱动程序]二进制路径的Jenkins Selenium插件配置中将其引用为tools\chromedrive\chromedriver.exe,并且Jenkins将在从属服务器特定的为您服务.

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

将Chrome安装到默认位置,该位置与所述C:\Program Files (x86)\Google\Chrome\Application\chrome.exe相同.

Installed Chrome to the default location which turned out to be C:\Program Files (x86)\Google\Chrome\Application\chrome.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硒的配置,您是否重新启动了硒服务,配置更改后它似乎停止了它们.配置中是否指定了实例?
  • 如果这是安装位置问题,则可以使用以下方法在测试用例中更改安装位置选项

  • 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托管的网格上使用Chromedriver设置Selenium的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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