当前位置: 首页 > 面试题库 >

无法从Jenkins CI启动浏览器

颜霖
2023-03-14
问题内容

从Jenkins构建后通过调用rake任务触发黄瓜测试时,我无法启动CI服务器上的浏览器(在我的情况下为Linux上的本地主机)。Jenkins控制台日志如下。我很确定所有设置都正确,因为我可以通过命令行在服务器上成功运行它。

01:26:43 [cucumber] $ /usr/local/rvm/scripts/gems/ruby-2.3.0/bin/rake schedule_win_job:features --trace

01:26:43 ** Invoke schedule_win_job:features (first_time)

01:26:43 ** Execute schedule_win_job:features

01:26:43 /usr/local/rvm/scripts/rubies/ruby-2.3.0/bin/ruby -S bundle exec cucumber --tag @schedule_job --profile dev

**01:27:45 unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055) (Selenium::WebDriver::Error::WebDriverError)**

01:27:45 /usr/local/rvm/scripts/gems/ruby-2.3.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver/firefox/launcher.rb:90:in `connect_until_stable'

01:27:45 /usr/local/rvm/scripts/gems/ruby-2.3.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver/firefox/launcher.rb:55:in `block in launch'

01:27:45 /usr/local/rvm/scripts/gems/ruby-2.3.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver/common/socket_lock.rb:43:in `locked'

01:27:45 /usr/local/rvm/scripts/gems/ruby-2.3.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver/firefox/launcher.rb:51:in `launch'

01:27:45 /usr/local/rvm/scripts/gems/ruby-2.3.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver/firefox/bridge.rb:43:in `initialize'

01:27:45 /usr/local/rvm/scripts/gems/ruby-2.3.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver/common/driver.rb:53:in `new'

01:27:45 /usr/local/rvm/scripts/gems/ruby-2.3.0/gems/selenium-html" target="_blank">webdriver-2.53.0/lib/selenium/webdriver/common/driver.rb:53:in `for'

01:27:45 /usr/local/rvm/scripts/gems/ruby-2.3.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver.rb:84:in `for'

01:27:45 /usr/local/rvm/scripts/gems/ruby-2.3.0/gems/watir-webdriver-0.9.1/lib/watir-webdriver/browser.rb:46:in `initialize'

问题答案:

事实证明,Jenkins用户的帐户性质不允许其在Jenkins服务器内运行GUI测试。

Firefox是GUI应用程序,它需要连接到X服务器以发送命令来绘制窗口等。通常,Jenkins被设置为作为后台系统守护程序运行,该后台守护程序无法访问任何X服务器会话。

这是尝试使用shell命令/ usr / bin / firefox在Jenkins构建中启动firefox时出现以下错误的原因。

No protocol specified

XDG_RUNTIME_DIR not set in the environment

Error: cannot open display: :0

因此,一种可能的解决方案是使用 pkexec
命令以root特权触发测试(可能可以将Jenkins用户添加到sudo组中,以便它可以成功运行命令,但是出于安全考虑,不建议这样做,我尝试不起作用)。

要使用 pkexec 实现完全自动化, 需要其他一些设置,例如,禁用身份验证提示。准备好逐步解决方案后,我将提供更详细的答案。



 类似资料:
  • 我对詹金斯真的很陌生。今天我安装并尝试玩。当然我丢了一把钥匙。 我的环境:java-version java version“1.6.0\u 24”OpenJDK Runtime environment(IcedTea6 1.11.4)(rhel-1.49.1.11.4.el6\u 3-x86\u 64)OpenJDK 64位服务器虚拟机(构建20.0-b12,混合模式) tomcat6型 Cen

  • 我无法启动CI服务器上的浏览器(localhostLinux在我的情况下)当触发cucumber测试通过调用rake任务后从Jenkins构建。詹金斯控制台日志如下。我很确定一切都设置正确,因为我可以通过命令行在服务器上成功运行它。

  • 问题内容: 我刚接触selenium。我生成了我的第一个Javaselenium测试用例,它已成功编译。但是当我运行该测试时,我得到了以下RuntimeException 请告诉我如何解决此错误。 这是我要运行的Java文件。 我首先通过命令提示符启动了selenium服务器,然后通过另一个命令提示符执行了上述java文件。 第二个问题:我可以右键单击包含selenium的网页上的指定位置。 问题

  • 我的代码: 例外情况 线程“main”java中出现异常。lang.IllegalStateException:驱动程序可执行文件不存在:C:\Users\sony\Downloads\chromedriver\U win32。在com.exe。谷歌。常见的基础先决条件。org上的checkState(premissions.java:534)。openqa。硒。遥远的服务司机服务。在org上检查

  • 线程“main”java.lang.IllegalStateException中的异常:驱动程序可执行文件的路径必须由WebDriver.Chrome.driver系统属性设置;有关更多信息,请参见https://github.com/seleniumhq/selenium/wiki/chromedriver。最新版本可从http://chromedriver.storage.googleapis

  • 我正在使用ChromeDriver V2.24,我的系统中有Chrome Browser52(未安装,可执行文件)。 NosuchSessionException:没有这样的会话 控制台: 注意:在Windows安全更新之前,当我使用ChromeDriver3.1和Chrome58时,我的脚本运行良好。更新后,我无法启动Chrome浏览器,因为它不是启动浏览器,而是在后台运行。