一次失败的Selenium chromedriver切换

发表于:2016-3-07 11:58

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:sdet_liang    来源:51Testing软件测试网采编

  背景
  Selenium webdriver一直使用Firefox作为浏览器来跑webtest, 但是最近发现ff有时会报超时的错误,于是想到使用chromedriver来提升稳定性。本想只把.firefox() 换成 .chrome() 这么简单的事情,结果却引出很多问题。
  做法
  1、根据官方文档
  2、下载chromedriver binary
  3、放到Linux 默认路径
  4、走起…
  5、问题来了
  问题
  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)
  排错
  1、用本机来跑, 排除Selenium Grid的因素
  2、更新Selenium和webdriver 到最新
  3、添加 –no-sandbox 参数
  4、还是跪了,用最小的测试依赖来跑,并生成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()
  后续
  1、在Mac上可以成功跑通,估计是测试环境上的问题
  2、Reported Bug https://bugs.chromium.org/p/chromedriver/issues/detail?id=397#c43
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号