google-chrome - WebDriver异常: Message: unknown error: unrecognized Chrome version: HeadlessChrome RobotFramework

标签 google-chrome selenium robotframework

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

headless 机器人

  *** 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 --版本

ChromeDriver 2.26.436382 (70eb799287ce4c2208441fc057053a5b07ceabac)

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

最佳答案

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

顺便说一句,不相关,该变量名为 ${options},但您传递了desired_capability ${preferences} - 复制和粘贴错误?

关于google-chrome - WebDriver异常: Message: unknown error: unrecognized Chrome version: HeadlessChrome RobotFramework,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44596897/

相关文章:

css - webkit 中的相对定位容器错误中的绝对定位元素 100% 宽度

python - ElementNotInteractableException : Message: Element <a> could not be scrolled into view

java - Selenium - 从 angularjs 组件中选择输入

SeleniumLibrary.Click Element with modifier CTRL 在 robotframework 执行中执行 Right Click+Ctrl

javascript - 将超文本链接的点击重新路由到外部URL,而不是到Electron应用程序之外的其他浏览器

google-chrome - 将图标添加到多功能框的 Chrome 扩展程序

python-3.x - 如何从以下html中提取数据?

xpath - Robot Framework无法通过xpath正确找到元素

robotframework - 机器人框架 : non-critical tag is not working

Chrome 上使用 ARC 的 Android 应用程序,启用后退按钮在顶部