我正在尝试在我的 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/