【问题标题】:Jenkins starts chromedriver in background mode (like headless mode)Jenkins 以后台模式启动 chromedriver(如无头模式)
【发布时间】:2020-03-13 19:15:09
【问题描述】:

我已经在 Windows 10 机器上设置了 Jenkins 服务器。运行作业时(只需mvn test -DsuiteXmlFile=%TestSuite%),作业成功编译并开始测试。我可以看到第一次被跳过,第二次失败,然后它开始一个接一个地通过。没有打开 Chrome 窗口,但是当我签入任务管理器时,我可以看到它在后台打开了几个 Chrome 进程。在 CMD 中调用 mvn test -DsuiteXmlFile=TestSuite 时(也在 power shell 中),它会在前面打开 Chrome。 查看 Jenkins 日志,我看到它在 c:/System/TEMP/ 目录中创建了一个 .bat 文件并执行该批处理文件。我什至尝试复制文件,放入项目的根目录并通过 CMD 调用它,相同的 .bat 文件按预期工作。詹金斯仍然在后台打开 Chrome。知道是什么原因造成的吗?如何强制 Jenkins 在前台运行测试?

我的 chromedriver 版本是 78.0.3904.70(如果需要)。 两种情况的日志是相同的:

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TestSuite
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
18.11.2019 03:50:38.019 INFO  - [AutomationListener]:Staring to run test suite with 11 tests
Nov 18, 2019 3:50:38 AM org.openqa.selenium.remote.DesiredCapabilities chrome
INFO: Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
Starting ChromeDriver 78.0.3904.70 (edb9c9f3de0247fd912a77b7f6cae7447f6d3ad5-refs/branch-heads/3904@{#800}) on port 39924
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1574077841.726][WARNING]: Timed out connecting to Chrome, retrying...
Nov 18, 2019 3:50:43 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
[1574077845.835][WARNING]: Timed out connecting to Chrome, retrying...
18.11.2019 03:50:55.489 INFO  - [BasePage]:The element: By.cssSelector: polygon is clicked
18.11.2019 03:50:55.494 INFO  - [AutomationListener]:----------------------------------------------------------------------
18.11.2019 03:50:55.495 INFO  - [AutomationListener]:Starting to run TestMethod test method
18.11.2019 03:50:55.495 INFO  - [AutomationListener]:----------------------------------------------------------------------

【问题讨论】:

  • 在windows系统上禁用防火墙后再次检查。

标签: selenium jenkins selenium-chromedriver


【解决方案1】:

当 Jenkins 从站作为服务在后台运行时,它启动的每个程序(如运行批处理文件)也将在后台运行。解决方案是在前台作为常规程序运行 Jenkins slave。

【讨论】:

  • 老实说我是 Windows 的新手 :) 曾经在 2008 年使用它 :)。然而,我没有slave,所有设置+测试都在同一台windows机器上运行,jenkins作为系统服务运行。
  • @AshotArakelyan 我明白了,我不是 devops,但这似乎是不寻常的设置。无论如何,这是在后台运行的问题。你可以创建 Jenkins slave,虽然它是本地的,然后在前台运行它,然后通过 slave 完成工作。
猜你喜欢
  • 2017-12-21
  • 2014-12-31
  • 1970-01-01
  • 2023-01-27
  • 1970-01-01
  • 1970-01-01
  • 2018-08-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多