【发布时间】: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