2

当我在 Eclipse 中运行 Selenium-Webdriver 脚本时,它运行良好。但是相同的脚本在服务器机器的詹金斯中运行,它给出了以下错误:

18:00:34 -------------------------------------------------------
18:00:34  T E S T S
18:00:34 -------------------------------------------------------
18:00:35 Running TestSuite
18:12:46 Tests run: 568, Failures: 16, Errors: 0, Skipped: 552, Time elapsed: 731.137          sec <<< FAILURE!
18:12:46 
18:12:46 Results :
18:12:46 
18:12:46 Failed tests:   setUp(com.abcd.fe.web.integration.myaccount.test.SettingsPageTest): Failed to connect to binary FirefoxBinary(/usr/bin/firefox) on port 7055; process output follows: 
18:12:46   setUp(com.abcd.fe.web.integration.footer.test.FooterMenuBottomTest): Failed to connect to binary FirefoxBinary(/usr/bin/firefox) on port 7055; process output follows: 
18:12:46   setUp(com.abcd.fe.web.integration.help.test.HelpPageTest): Failed to connect to binary FirefoxBinary(/usr/bin/firefox) on port 7055; process output follows: 
18:12:46   setUp(com.abcd.fe.web.integration.myaccount.test.MyAccountPageTest): Failed to connect to binary FirefoxBinary(/usr/bin/firefox) on port 7055; process output follows: 
18:12:46   setUp(com.abcd.fe.web.integration.loginsignup.test.SignupPageTest): Failed to connect to binary FirefoxBinary(/usr/bin/firefox) on port 7055; process output follows: 

18:12:46 
18:12:46 Tests run: 568, Failures: 16, Errors: 0, Skipped: 552
18:12:46 
18:12:46 [ERROR] There are test failures.
18:12:46 
18:12:46 Please refer to /var/lib/jenkins/jenkins/workspace/fe-abcd-xyz- integration-test/target/surefire-reports for the individual test results.
18:12:46 [JENKINS] Recording test results
18:12:48 [INFO] 
18:12:48 [INFO] --- maven-install-plugin:2.3.1:install (default-install) @ abcd-xyz-test ---
18:12:48 [INFO] Installing /var/lib/jenkins/jenkins/workspace/fe-abcd-xyz-integration-test/target/abcd-xyz-test-2.0.0-SNAPSHOT.jar to /home/jenkins/.m2/repository/com/abcd/test/fe/functional/abcd-xyz-test/2.0.0-SNAPSHOT/abcd-xyz-test-2.0.0-SNAPSHOT.jar
18:12:48 [INFO] Installing /var/lib/jenkins/jenkins/workspace/fe-abcd-xyz-integration-test/pom.xml to /home/jenkins/.m2/repository/com/abcd/test/fe/functional/abcd-xyz-test/2.0.0-SNAPSHOT/abcd-xyz-test-2.0.0-SNAPSHOT.pom
18:12:48 [INFO] ------------------------------------------------------------------------
18:12:48 [INFO] BUILD SUCCESS
18:12:48 [INFO] ------------------------------------------------------------------------
18:12:48 [INFO] Total time: 12:23.959s
18:12:48 [INFO] Finished at: Thu Aug 29 18:12:48 PDT 2013
18:12:48 [INFO] Final Memory: 25M/198M
18:12:48 [INFO] ------------------------------------------------------------------------
18:12:49 [JENKINS] Archiving disabled
18:12:49 Waiting for Jenkins to finish collecting data
18:12:49 Sending e-mails to: abcd-xyz-dev@abcd.com abcd-xyz-qa@abcd.com
18:12:49 channel stopped
18:12:49 [ANALYSIS-COLLECTOR] Computing warning deltas based on reference build #589
18:12:49 TestNG Reports Processing: START
18:12:49 Looking for TestNG results report in workspace using pattern: **/target/surefire-reports/testng-results.xml
18:12:49 Saving reports...
18:12:49 Processing '/var/lib/jenkins/jenkins/jobs/fe-abcd-xyz-integration-test/builds/2013-08-29_18-00-18/testng/testng-results.xml'
18:12:49 TestNG Reports Processing: FINISH
18:12:49 Sending e-mails to: abcd-xyz-dev@abcd.com abcd-xyz-qa@abcd.com
18:12:49 [ci-game] evaluating rule: Build result
18:12:49 [ci-game] evaluating rule: Increased number of failed tests
18:12:49 [ci-game] evaluating rule: Increased number of passed tests
18:12:49 [ci-game] evaluating rule: Decreased number of failed tests
18:12:49 [ci-game] evaluating rule: Decreased number of passed tests
18:12:49 [ci-game] evaluating rule: Open HIGH priority tasks
18:12:49 [ci-game] evaluating rule: Open NORMAL priority tasks
18:12:49 [ci-game] evaluating rule: Open LOW priority tasks
18:12:49 [ci-game] evaluating rule: PMD violation
18:12:49 [ci-game] evaluating rule: pylint violation
18:12:49 [ci-game] evaluating rule: CPD violation
18:12:49 [ci-game] evaluating rule: Checkstyle violation
18:12:49 [ci-game] evaluating rule: FindBugs violation
18:12:49 [ci-game] evaluating rule: FXCop violation
18:12:49 [ci-game] evaluating rule: Simian violation
18:12:49 [ci-game] evaluating rule: StyleCop violation
18:12:49 [ci-game] evaluating rule: HIGH priority PMD warnings
18:12:49 [ci-game] evaluating rule: NORMAL priority PMD warnings
18:12:49 [ci-game] evaluating rule: LOW priority PMD warnings
18:12:49 [ci-game] evaluating rule: New HIGH priority Findbugs warnings
18:12:49 [ci-game] evaluating rule: New NORMAL priority Findbugs warnings
18:12:49 [ci-game] evaluating rule: New LOW priority Findbugs warnings
18:12:49 [ci-game] evaluating rule: Fixed HIGH priority Findbugs warnings
18:12:49 [ci-game] evaluating rule: Fixed NORMAL priority Findbugs warnings
18:12:49 [ci-game] evaluating rule: Fixed LOW priority Findbugs warnings
18:12:49 [ci-game] evaluating rule: Changed number of compiler warnings
18:12:49 Notifying upstream projects of job completion
18:12:49 Finished: UNSTABLE

我在 porm.xml selenium.server 版本中遇到的错误是 2.33.0,服务器中的 Firefox 版本是 10.0。从 3 天开始,我就遇到了这个问题,在它运行良好之前。为什么它在本地机器上运行以及为什么它不在 Jenkins 中运行。

4

3 回答 3

0

更新 Ubuntu 后我遇到了这个问题。我的问题是 Firefox 版本不同,为了防止将来出现问题,请关闭自动更新。

这有助于解决我的问题: Failed to connect to binary FirefoxBinary with Selenium in Maven

于 2015-02-27T10:21:50.683 回答
0

首先通过本地测试修复您的 Firefox 版本和 selenium 版本匹配。如果您正在通过 Jenkins 运行作业并且在日志中您会收到错误 Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms。Firefox 控制台输出:错误:无法打开显示::0

要解决请看以下步骤:

1) Firefox 仅在您运行 Xvfb 时才会启动,
例如: Xvfb :15 -screen 0 1024x768x16 所以首先检查这个,您可以通过将 ps -ef 添加到作业的前置步骤(shell 执行)中来将此检查包含到作业中。

2)即使您已经明确定义了 DISPLAY 值但仍然有错误,那么最好的方法是在 Jenkins 作业本身中注入环境值。在Build environment >> Inject env variables >> Properties content >> DISPLAY=:15 下(您可以根据自己的选择显示,但同样应该在 xvfb 中运行)

!!运行你的工作,应该已经修复。

于 2017-08-09T12:06:09.897 回答
-2

尝试使用以下内容:

System.setProperty("webdriver.firefox.bin","C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
于 2013-08-30T06:08:10.823 回答