2013-04-23 159 views
0

我想在詹金斯設置一個簡單的硒測試。我的操作系統是Debian GNU/Linux 6.0.7(squeeze),桌面版本(64位)。我卸載了提供的瀏覽器iceweasel,並用aptitude安裝了Firefox。 Firefox的版本是「20.0」。我也安裝了谷歌瀏覽器。我可以通過在終端窗口中編寫「firefox」來運行Firefox。 Jenkins與aptitude一起安裝。詹金斯和Seleniumhq配置

因此,我在Jenkins中安裝了一個名爲Seleniumhq的插件。這是我的設置:

enter image description here

然後我收到一個錯誤的詹金斯控制檯時,我嘗試建立:

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 [email protected] 
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 [email protected] 
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 

我也試圖把這個在瀏覽器領域: *火狐/ usr/bin/firefox 我認爲Firefox安裝在那裏(我運行「找到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 
.... 

是否有人對如何解決這個想法? 謝謝!

編輯

我更改了瀏覽器設置來: *火狐的/ opt /火狐/火狐(帶之間的空間) 現在看來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 [email protected] 
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 [email protected] 
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 
+0

嘗試增加火狐20.0路徑使用導出CLASSPATH聲明。 – Hemanth 2013-04-23 11:58:12

+0

你的意思是在Jenkins系統配置中?應該在哪裏做? – Jojje 2013-04-23 12:03:25

+0

在您運行selenium腳本的系統的終端中運行以下命令。 'export CLASSPATH =%path%;你的firefox二進制文件的路徑' – Hemanth 2013-04-23 12:05:51

回答

0
java.lang.RuntimeException: Browser not supported: *firefox/usr/bin/firefox 

語法錯誤。嘗試* firefox或* firefox [插入目錄]

1

你應該嘗試從shell運行命令行,看看會發生什麼。這當然是一個問題,它與硒所使用的Firefox的默認配置文件有關。

在我的情況下,問題是,Firefox是通過顯示可以恢復的選項卡開始。

您也可以嘗試創建一個特定的配置文件: firefox -pfirefox -ProfileManager

然後使用命令行參數使用專用的個人資料:
-firefoxProfileTemplate /home/userXXX/.mozilla/firefox/ljhyckqd.Selenium

+0

這個解決方案爲我在Debian 3.2.0-4-amd64上運行Firefox從這個Repo工作:deb http://packages.linuxmint.com debian import。但是,一旦我從命令提示符運行配置文件管理器並添加了配置文件,我不必使用'-P'或'-firefoxProfileTemplate'指定配置文件。我只需在Jenkins的瀏覽器框中指定'* firefox'就足夠了>> SeleniumHQ設置 – 2014-12-10 11:52:23

+0

真正有用的Selenium Server命令行選項[鏈接] http://eswarg.blogspot.com.tr/2013/06/selenium -server-命令行,options.html – 2014-12-10 11:56:38