WebDriverError 错误:Chrome 无法启动:异常退出 [英] WebDriverError error: Chrome failed to start: exited abnormally
问题描述
我正在尝试在 ubuntu 14.04 vm(通过谷歌云)上运行量角器测试,出于某种原因,当我运行量角器 conf.js"时,我收到一条错误消息:
I'm trying to run protractor test on ubuntu 14.04 vm (by google cloud), for some reason when i run 'protractor conf.js' i get an error says:
E/launcher - WebDriverError:未知错误:Chrome 无法启动:异常退出
我按照以下任务安装无头 chrome:https://gist.github.com/alonisser/11192482
I followed this tasks in order to install headless chrome: https://gist.github.com/alonisser/11192482
在运行 protractor cons.js 之前,我正在运行 "webdriver-manager start"
当我运行 'Xvfb -ac :2 -screen 0 1280x1024x16' 时,它会冻结'初始化内置扩展 GLX'
When i run 'Xvfb -ac :2 -screen 0 1280x1024x16' its freeze when gets to 'Initializing built-in extension GLX'
我也尝试将 conf.js 更改为铬选项:{参数:[--headless",--disable-gpu",--window-size=800x600"]'但是量角器打印'start'然后错误:'失败:未知错误:键码转换需要X显示,考虑使用Xvfb'
I also tried change the conf.js to chromeOptions: { args: [ "--headless", "--disable-gpu", "--window-size=800x600" ]' but and protractor print 'start' then error: 'Failed: unknown error: an X display is required for keycode conversions, consider using Xvfb'
值得一提的是,在几个小时之前,一切都运行良好.然后我就让我的mac休眠了,当然是退出了vm..
It's important to mention that it's all worked great, before a couple hours. then i just let my mac sleep, and of course it was exit the vm..
我正在我的 mac 中使用量角器运行相同的测试,它的效果很好.问题与实例 vm 上的 chrome/chromeDriver 有关.
I'm running the same tests with protractor in my mac and its works great. the problem is related to chrome/chromeDriver on the instance vm.
非常感谢!!!
推荐答案
我在 AWS EC2 机器上使用 selenium + python 2.7 + chromedriver 时遇到了类似的问题.
I had a similar problem when using selenium + python 2.7 + chromedriver in a AWS EC2 machine.
就我而言,我使用的是最新的无头功能,因此向 ChromeOptions 对象添加 'no-sandbox' 参数就可以了.
In my case I was using the newest headless feature, so adding 'no-sandbox' parameter to the ChromeOptions object did the trick.
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('headless')
chrome_options.add_argument('no-sandbox')
driver = webdriver.Chrome(chrome_options=chrome_options)
问题似乎是 chrome 的权限问题.它不允许root"用户在没有 --no-sandbox 标志的情况下执行它
The problem seems to be a permission issue with chrome. It does not allow a 'root' user to execute it without the --no-sandbox flag
这篇关于WebDriverError 错误:Chrome 无法启动:异常退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!