您的位置:首页 > 其它

一次失败的Selenium chromedriver切换

2016-02-15 14:25 288 查看

背景

Selenium webdriver一直使用Firefox作为浏览器来跑webtest, 但是最近发现ff有时会报超时的错误,于是想到使用chromedriver来提升稳定性。本想只把.firefox() 换成 .chrome() 这么简单的事情,结果却引出很多问题。

做法

根据官方文档

下载chromedriver binary

放到Linux 默认路径

走起…

问题来了

问题

Selenium 报无法启动chrome, 报错

selenium.common.exceptions.WebDriverException: Message: chrome not reachable
(Driver info: chromedriver=2.21.371461 (633e689b520b25f3e264a2ede6b74ccc23cb636a),platform=Linux 3.0.36-gentoo x86_64)


排错

用本机来跑, 排除Selenium Grid的因素

更新Selenium和webdriver 到最新

添加 –no-sandbox 参数

还是跪了,用最小的测试依赖来跑,并生成chromedriver log,把问题丢给google chrome 团队了

test_chrom_min.py

from selenium import webdriver

service_log_path = 'chromedriver.log'
service_args = ['--verbose', '--no-sandbox']

driver = webdriver.Chrome('/usr/bin/chromedriver', service_args=service_args,
service_log_path=service_log_path)
driver.get('http://www.google.com/xhtml')
driver.quit()


后续

在Mac上可以成功跑通,估计是测试环境上的问题

Reported Bug https://bugs.chromium.org/p/chromedriver/issues/detail?id=397#c43
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: