CUI环境下Selenium+chrome最新headless特性的问题
我的环境:
- Docker jessie
- Python 3.4
- Selenium 3
- Chrome59
- chrome webdriver 2.30
官方推荐的使用方法:https://intoli.com/blog/running-selenium-with-headless-chrome/
我的参数是:
1 | options = webdriver.ChromeOptions() |
执行官方示例时出现下面的错误:
1 | selenium.common.exceptions.WebDriverException: Message: unknown error: an X display is required for keycode conversions, consider using Xvfb |
chrome headless时刚更新的特性,搜索到的文章大多都是用的xvfb,只找到一位日本同学绕开了这个问题。其实google官方就有专门说selenimu还不能很好的支持新的headless,实际使用时主要在sendkeys时出错,日本同学用js绕过了这个错误。方法如下:
1 | # driver.get_element_by_css_selector('hoge').sendKeys('fuga') は例外が発生 |
CUI环境下Selenium+chrome最新headless特性的问题
https://jinzhao.me/2017/07/02/2017/2017-07-02-cui环境下seleniumchrome最新headless特性的问题/
You need to set
install_url to use ShareThis. Please set it in _config.yml.