0

我正在尝试在 Jenkins 中设置一个简单的 Selenium 测试。我的操作系统是 Debian GNU/Linux 6.0.7(挤压),桌面版(64 位)。我卸载了提供的浏览器 iceweasel 并安装了 Firefox 的 aptitude。Firefox 版本是“20.0”。我也安装了谷歌浏览器。我可以通过在终端窗口中写入“firefox”来运行 Firefox。Jenkins 安装了 aptitude。

所以,我在 Jenkins 中安装了一个名为 Seleniumhq 的插件。这些是我的设置:

在此处输入图像描述

然后,当我尝试构建时,我在 Jenkins 控制台中收到错误消息:

Started by user anonymous
Building in workspace /var/lib/jenkins/workspace/selenium2
java -jar /var/lib/jenkins/selenium-server-standalone-2.0b2.jar -trustAllSSLCertificates      -htmlSuite *firefox http://site.com /var/lib/jenkins/jobs/Selenium1/suites/suite1.html   /var/lib/jenkins/jobs/Selenium1/logs/selenium.html
[selenium2] $ java -jar /var/lib/jenkins/selenium-server-standalone-2.0b2.jar -   trustAllSSLCertificates -htmlSuite *firefox http://site.com      /var/lib/jenkins/jobs/Selenium1/suites/suite1.html    /var/lib/jenkins/jobs/Selenium1/logs/selenium.html
 13:32:18.507 INFO - Java: Sun Microsystems Inc. 14.0-b16
 13:32:18.508 INFO - OS: Linux 2.6.32-5-amd64 amd64
 13:32:18.512 INFO - v2.0 [b2], with Core v2.0 [b2]
 13:32:18.604 INFO - RemoteWebDriver instances should connect to:      http://127.0.0.1:4444/wd/hub
 13:32:18.605 INFO - Version Jetty/5.1.x
13:32:18.606 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
13:32:18.606 INFO - Started HttpContext[/selenium-server,/selenium-server]
13:32:18.607 INFO - Started HttpContext[/,/]
13:32:18.616 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@488e32e7
13:32:18.616 INFO - Started HttpContext[/wd,/wd]
13:32:18.621 INFO - Started SocketListener on 0.0.0.0:4444
13:32:18.621 INFO - Started org.openqa.jetty.jetty.Server@5a5e5a50
HTML suite exception seen:
java.lang.RuntimeException: java.lang.RuntimeException: Firefox 3 could not be found in    the path!
Please add the directory containing ''firefox-bin' or 'firefox'' to your PATH   environment
 variable, or explicitly specify a path to Firefox 3 like this:
*firefox3/blah/blah/firefox-bin
at    org.openqa.selenium.server.browserlaunchers.BrowserLauncherFactory.createBrowserLauncher(Bro wserLauncherFactory.java:160)
at  org.openqa.selenium.server.browserlaunchers.BrowserLauncherFactory.getBrowserLauncher(Browse rLauncherFactory.java:99)
at    org.openqa.selenium.server.htmlrunner.HTMLLauncher.getBrowserLauncher(HTMLLauncher.java:58)
at org.openqa.selenium.server.htmlrunner.HTMLLauncher.runHTMLSuite(HTMLLauncher.java:114)
at org.openqa.selenium.server.htmlrunner.HTMLLauncher.runHTMLSuite(HTMLLauncher.java:166)
at org.openqa.selenium.server.SeleniumServer.runHtmlSuite(SeleniumServer.java:557)
at org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:250)
at org.openqa.selenium.server.SeleniumServer.main(SeleniumServer.java:210)
  Caused by: java.lang.RuntimeException: Firefox 3 could not be found in the path!
  Please add the directory containing ''firefox-bin' or 'firefox'' to your PATH environment
  variable, or explicitly specify a path to Firefox 3 like this:
 *firefox3/blah/blah/firefox-bin
at org.openqa.selenium.browserlaunchers.locators.Firefox2or3Locator.findBrowserLocationOrFail(Firefox2or3Locator.java:26)
at org.openqa.selenium.server.browserlaunchers.BrowserInstallationCache.locateBrowserInstallation(BrowserInstallationCache.java:27)
at org.openqa.selenium.server.browserlaunchers.FirefoxLauncher.<init>(FirefoxLauncher.java:52)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at org.openqa.selenium.server.browserlaunchers.BrowserLauncherFactory.createBrowserLauncher(BrowserLauncherFactory.java:153)
... 7 more
 Finished: SUCCESS

我还尝试将其放在浏览器字段中: *firefox/usr/bin/firefox 我认为 firefox 已安装在那里(我运行了“locate firefox”)。该配置呈现另一个错误消息:

...
HTML suite exception seen:
java.lang.RuntimeException: Browser not supported: *firefox/usr/bin/firefox

Supported browsers include:
*firefox
*mock
*firefoxproxy
*pifirefox
*chrome
*iexploreproxy
*iexplore
*firefox3
*safariproxy
*googlechrome
*konqueror
*firefox2
*safari
*piiexplore
*firefoxchrome
*opera
*iehta
*custom 
....

有人对如何解决这个问题有想法吗?谢谢!

编辑

我将浏览器设置更改为: *firefox /opt/firefox/firefox(之间有空格) 现在似乎可以找到 FIrefox,但我收到另一个错误:

 Started by user anonymous
 Building in workspace /var/lib/jenkins/workspace/selenium2
 java -jar /var/lib/jenkins/selenium-server-standalone-2.0b2.jar -trustAllSSLCertificates -htmlSuite *firefox /opt/firefox/firefox http://site.com   /var/lib/jenkins/jobs/selenium2/suites/suite1.html   /var/lib/jenkins/jobs/selenium2/logs/selenium.html
 [selenium2] $ java -jar /var/lib/jenkins/selenium-server-standalone-2.0b2.jar -    trustAllSSLCertificates -htmlSuite "*firefox /opt/firefox/firefox" http://site.com  /var/lib/jenkins/jobs/selenium2/suites/suite1.html  /var/lib/jenkins/jobs/selenium2/logs/selenium.html
 10:51:15.567 INFO - Java: Sun Microsystems Inc. 14.0-b16
 10:51:15.569 INFO - OS: Linux 2.6.32-5-amd64 amd64
 10:51:15.572 INFO - v2.0 [b2], with Core v2.0 [b2]
 10:51:15.668 INFO - RemoteWebDriver instances should connect to:     http: //127.0.0.1:4444/wd/hub
 10:51:15.669 INFO - Version Jetty/5.1.x
 10:51:15.669 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
 10:51:15.670 INFO - Started HttpContext[/selenium-server,/selenium-server]
 10:51:15.670 INFO - Started HttpContext[/,/]
 10:51:15.680 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@3da99561
 10:51:15.680 INFO - Started HttpContext[/wd,/wd]
 10:51:15.685 INFO - Started SocketListener on 0.0.0.0:4444
 10:51:15.685 INFO - Started org.openqa.jetty.jetty.Server@182d9c06
 10:51:15.743 INFO - Preparing Firefox profile...
HTML suite exception seen:
 java.lang.NullPointerException
at org.openqa.selenium.os.CommandLine.destroy(CommandLine.java:259)
at  org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.populateCustomProfileDirec tory(FirefoxChromeLauncher.java:117)
at  org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.launch(FirefoxChromeLauncher.java:84)
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.launchHTMLSuite(FirefoxChromeLauncher.java:406)
at org.openqa.selenium.server.browserlaunchers.FirefoxLauncher.launchHTMLSuite(FirefoxLauncher.java:106)
at  org.openqa.selenium.server.htmlrunner.HTMLLauncher.runHTMLSuite(HTMLLauncher.java:121)
at org.openqa.selenium.server.htmlrunner.HTMLLauncher.runHTMLSuite(HTMLLauncher.java:166)
at org.openqa.selenium.server.SeleniumServer.runHtmlSuite(SeleniumServer.java:557)
at org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:250)
at org.openqa.selenium.server.SeleniumServer.main(SeleniumServer.java:210)
  10:51:35.789 INFO - Shutting down...
  Finished: SUCCESS
4

3 回答 3

1

您应该尝试从 shell 运行命令行,看看会发生什么。这肯定是与 selenium 实例化的 firefox 使用的默认配置文件相关的问题。

在我的情况下,问题是firefox是通过显示可以恢复的选项卡开始的。

您也可以尝试创建特定的配置文件: firefox -pfirefox -ProfileManager

然后使用命令行参数使用这个专用配置文件:
-firefoxProfileTemplate /home/userXXX/.mozilla/firefox/ljhyckqd.Selenium

于 2014-05-13T16:35:56.090 回答
1

好吧,我找到了一个很好的教程,结果证明它很有用。一件重要的事情是在服务器上启动一个虚拟 X 窗口,Selenium 可以在其中启动浏览器以运行您的测试 (Xvfb)。在 Jenkins 中,服务器应该像“*firefox”一样输入。

http://alex.nederlof.com/blog/2012/11/19/installing-selenium-with-jenkins-on-ubuntu/

于 2013-05-06T14:42:04.863 回答
0
java.lang.RuntimeException: Browser not supported: *firefox/usr/bin/firefox

语法错误。尝试 *firefox 或 *firefox [插入目录]

于 2013-05-10T06:55:28.577 回答