2017-06-16 43 views
4

我嘗試使用谷歌鉻無頭功能在我的Ubuntu的機器上運行腳本硒無頭。繼是,我運行WebDriverException:消息:未知的錯誤:無法識別的Chrome版本:HeadlessChrome RobotFramework

無頭的腳本。機器人

*** 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)

谷歌鉻--version

谷歌瀏覽器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 

回答

2

升級chromedriver最新 - 目前v2.30;這個問題應該在v2.29中得到解決(而且你的年齡比較大)。
另外,according to the doc您需要取消註釋remote_debugging_port的說法。

順便說一句,無關,變量被稱爲${options},但你傳入desired_capabilities ${preferences} - 複製和粘貼錯誤?

+0

感謝您的回答@Todor,我會嘗試更新我的chromedriver版本並更新答案。偏好部分是在發佈問題時由我複製粘貼錯誤。 – Madhu

+1

此問題在升級到最新的chromedriver版本2.30後解決。謝謝@Todor – Madhu

相關問題