WebDriverException:消息:未知错误:无法识别的Chrome版本:HeadlessChrome RobotFramework

时间:2017-06-16 19:45:39

标签: google-chrome selenium robotframework

我正在尝试在我的ubuntu机器上使用google-chrome无头功能来运行无头脚本。以下是我正在运行的脚本

headless.robot

  *** Settings ***
    Documentation     This example demonstrates how to use current library
    Library      Selenium2Library

    *** Test cases ***
   Open Browser with Chrome options in headless mode
        ${options}  Evaluate  sys.modules['selenium.webdriver'].ChromeOptions()  sys, selenium.webdriver
        Call Method  ${options}  add_argument  --start-maximized
        Call Method  ${options}  add_argument  --headless
        Call Method  ${options}  add_argument  --disable-gpu
        #Call Method  ${options}  add_argument  --remote-debugging-port=${9222}
        Create WebDriver  Chrome    chrome_options=${options}
        Go To    https://www.google.com    
        ${title}=    Get Title    
        Log to console    ${title}

pybot headless.robot

==============================================================================
Headless :: This example demonstrates how to use current library              
==============================================================================
[ WARN ] Keyword 'Capture Page Screenshot' could not be run on failure: No browser is open
Open Browser with Chrome options for configuring data source          | FAIL |
WebDriverException: Message: unknown error: unrecognized Chrome version: HeadlessChrome/59.0.3071.86
  (Driver info: chromedriver=2.26.436382 (70eb799287ce4c2208441fc057053a5b07ceabac),platform=Linux 3.13.0-119-generic x86_64)
------------------------------------------------------------------------------
Headless :: This example demonstrates how to use current library      | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
==============================================================================
Output:  /var/robot-tests/output.xml
Log:     /var/robot-tests/log.html
Report:  /var/robot-tests/report.html

chromedriver --version

ChromeDriver 2.26.436382(70eb799287ce4c2208441fc057053a5b07ceabac)

google-chrome --version

Google Chrome 59.0.3071.86

安装了依赖项模块

apt-get install -y xvfb fluxbox x11vnc dbus libasound2 libqt4-dbus libqt4-network libqtcore4 libqtgui4 libxss1 libpython2.7 libqt4-xml libaudio2 fontconfig liblcms1 lib32stdc++6 libc6-i386 lib32gcc1 nano

1 个答案:

答案 0 :(得分:2)

chromedriver升级到最新版本 - 目前为v2.30;这个问题应该在v2.29中修复(你的年龄较大) 另外,according to the doc您需要取消注释remote_debugging_port参数。

顺便说一句,无关,变量名为${options},但是你传递了desired_capabilities ${preferences} - 复制和粘贴错误?

相关问题