【问题标题】:Chromedriver crashes once running with JenkinsChromedriver 与 Jenkins 一起运行后崩溃
【发布时间】:2017-11-02 04:24:02
【问题描述】:

我已经使用 Robotframework 创建了 Web 测试。 一旦我尝试使用 Jenkins 运行测试,由于 chromedriver 在启动时崩溃,测试会失败。这是我收到的消息:

WebDriverException:消息:未知错误:Chrome 无法启动:崩溃 (驱动信息:chromedriver=2.29.461585 (0be2cd95f834e9ee7c46bcc7cf405b483f5ae83b),platform=Mac OS X 10.12.4 x86_64)

尝试手动运行成功,一切正常。

这是我正在运行的精简代码:

*** Test Cases ***
Test Sanity Setup
    [Tags]    Sanity
    ${chrome_options} =     Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys, selenium.webdriver
    ${prefs}    Create Dictionary   credentials_enable_service=${false}
    Call Method    ${chrome_options}    add_experimental_option    prefs    ${prefs}
    Call Method    ${chrome_options}    add_argument    --disable-infobars
    Call Method    ${chrome_options}    add_argument    --kiosk
    Create WebDriver    Chrome      chrome_options=${chrome_options}
Go to URL
    Go To  ${URL}


Finalize Tests
    close all browsers


*** Keywords ***
Provided precondition
Setup chromedriver
  Set Environment Variable  webdriver.chrome.driver  ./driver/chromedriver.exe

【问题讨论】:

  • 也许问题是我必须使用无头浏览器,因为我在远程机器上运行 Jenkins 仍在研究这种方式......
  • 为了帮助我们,我们需要进一步了解您的设置。 Jenkins 是作为 PoC 环境在您自己的桌面上运行,还是在具有不同操作系统(Linux、Windows 等)的服务器上运行?在 Jenkins 中,您是在运行从节点的测试,还是在服务器本身上运行?您能否提供 Jenkins 用于启动 Robot Framework 测试的确切命令,当然还有您用于手动运行测试的命令?
  • 感谢您的回复,Jenkins 在 Mac 上运行,作业在从节点上执行。在这两种情况下,我都运行相同的命令:'robot sanity.robot'
  • 从节点是windows机器,手动执行这个脚本在从节点上运行find?否则:Set Environment Variable webdriver.chrome.driver ./driver/chromedriver.exe 在 Mac 环境中没有意义。
  • 从机是Mac,请忽略错误添加的“.exe”

标签: jenkins selenium-chromedriver robotframework


【解决方案1】:

您能否详细说明您让 Jenkins 运行此测试的操作系统是什么?该代码表明您的本地计算机是 Windows,因为您将 webdriver.chrome.driver 设置为 Windows .exe?这不适用于 Linux 和 Mac 机器。

可以在here找到在 Linux 和 Windows 上运行 Headless Chrome 的手册。

PS:Headless Chrome 很快就会在 Chrome 59 中支持 Linux 和 Mac,但是 Selenium 和 Selenium-chrome-driver 也需要一些时间才能支持它。

【讨论】:

  • 感谢您的回复,实际上这是一个错误,因为我使用 Mac 机器作为 Jenkins 从机(但它仍然在运行 chromedriver)
猜你喜欢
  • 2017-04-16
  • 2014-04-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多