【问题标题】:WebDriver, ChromeDriver, Selenium, and Jenkins IntegrationWebDriver、ChromeDriver、Selenium 和 Jenkins 集成
【发布时间】:2015-09-12 22:19:17
【问题描述】:

我有一个用 Eclipse 编写的 selenium 脚本,它调用一个 ChromeDriver,它启动一个 URL、读取标题并关闭浏览器。我能够在 Eclipse 中以及在命令提示符下成功执行此操作。

但是,当我使用构建例程(通过执行批处理命令)创建 Jenkins 作业时,构建会持续运行很长时间。在使用 sysout 语句进行跟踪后,我发现构建在 drive.get() 处停止

driver.get("google.com");

等待很长时间后构建失败并出现以下错误消息:

Starting ChromeDriver 2.15.322448 (52179c1b310fec1797c81ea9a20326839860b7d3) on port 39626
Only local connections are allowed.
[304.538][SEVERE]: Timed out receiving message from renderer: 298.714
[904.539][SEVERE]: Timed out receiving message from renderer: 600.000
[914.540][SEVERE]: Timed out receiving message from renderer: 10.000

Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE

【问题讨论】:

    标签: java selenium jenkins selenium-webdriver selenium-chromedriver


    【解决方案1】:

    Selenium Webdriver 实际上需要显示才能工作(准确地说是 X 服务器)。

    你可以使用Xvfb在无头模式下运行它,详细说明(有点过时,但仍然有效)-http://alex.nederlof.com/blog/2012/11/19/installing-selenium-with-jenkins-on-ubuntu/

    【讨论】:

    • 感谢您提供详细信息。我通读了文档并安装了与 Windows 等效的 xvnv 插件。 link 但这并没有解决问题。我仍然面临同样的问题。
    • Hm...您可以在运行构建时仔细检查 DISPLAY 变量是否已定义?您可以在 Jenkins 中使用“执行 shell”构建步骤并打印变量。
    • 我重新安装了我的 JDK,jenkins,并在一个 maven 项目中尝试了同样的方法。构建作业按执行运行良好。我没有配置 selenium grid/xvnv。
    【解决方案2】:

    你得把代码改成

    driver.get("http://google.com");
    

    您一定已经看到从 eclipse 和命令提示符运行的错误。

    【讨论】:

    • 我在这里的问题中没有提到 http。但我的源代码中有这个。你是对的,从 soruce 调用任何 url 都需要 http 或 https。
    • 如果你的源代码中有http,我看不到它。我只能看到你在这里输入的内容。标记答案有什么意义。态度不好!!!
    猜你喜欢
    • 2013-07-26
    • 2020-08-16
    • 2018-06-25
    • 2018-07-31
    • 2014-08-20
    • 2013-03-08
    • 2015-10-10
    • 1970-01-01
    • 2015-01-07
    相关资源
    最近更新 更多