背景

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

做法

根据官方文档

  1. 下载chromedriver binary
  2. 放到Linux 默认路径
  3. 走起…
  4. 问题来了

问题

Selenium 报无法启动chrome, 报错

selenium.common.exceptions.WebDriverException: Message: chrome not reachable
(Driver info: chromedriver=2.21. (633e689b520b25f3e264a2ede6b74ccc23cb636a),platform=Linux 3.0.-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

一次失败的Selenium chromedriver切换的更多相关文章

  1. 用C#+Selenium+ChromeDriver 生成我的咕咚跑步路线地图

    先上结果: 之前 在公司业务中用过java+Selenium+ChromeDriver ,使用起来非常顺手,可以完美模拟真实的用户浏览行为.最近休息的时候想用C#也试一下,于是有了本文. 实现原理一样 ...

  2. ASP.NET MVC WebApi 返回数据类型序列化控制(json,xml) 用javascript在客户端删除某一个cookie键值对 input点击链接另一个页面,各种操作。 C# 往线程里传参数的方法总结 TCP/IP 协议 用C#+Selenium+ChromeDriver 生成我的咕咚跑步路线地图 (转)值得学习百度开源70+项目

    ASP.NET MVC WebApi 返回数据类型序列化控制(json,xml)   我们都知道在使用WebApi的时候Controller会自动将Action的返回值自动进行各种序列化处理(序列化为 ...

  3. selenium + ChromeDriver 实战系列之启信宝(一)

    之前写了一篇selenium + ChromeDriver的一些入门的知识,这篇博客里面找了启信宝这个网站,简单的进行了一个实战练习.本篇博客的结构如下:       首先会给出一些使用seleniu ...

  4. python网课自动刷课程序-------selenium+chromedriver

    python的强大之处就在于有许多已经写好的功能库提供,这些库强大且易用,对于写一些有特定功能的小程序十分方便. 现在就用pyhton的selenium+谷歌游览器写一个可以自动刷课的程序,以智慧树上 ...

  5. python+selenium+chromedriver抓取shodan搜索结果

    作用:免积分抓取shodan的搜索结果,并把IP保存为txt 前提: ①shodan会员(ps:黑色星期五打折) ②安装有python27 ③谷歌浏览器(ps:版本一定要跟chromedriver匹配 ...

  6. selenium + ChromeDriver

    Selenium是一个用于Web应用程序测试的工具.Selenium测试直接运行在浏览器中,就像真正的用户在操作一样.而对于爬虫来说,使用Selenium操控浏览器来爬取网上的数据那么肯定是爬虫中的杀 ...

  7. 使用Selenium+ChromeDriver登录微博并且获取cookie

    using OpenQA.Selenium;using OpenQA.Selenium.Chrome; public class GetSinaCookie { private static stri ...

  8. selenium中切换浏览器不同tab 的操作

    from selenium import webdriverimport timedriver=webdriver.Chrome()driver.get('http://ui.imdsx.cn/uit ...

  9. 无界面Ubuntu服务器搭建selenium+chromedriver+VNC运行环境

    搭建背景 有时候我们需要把基于selenium的爬虫放到服务器上跑的时候,就需要这样一套运行环境,其中VNC是虚拟的显示模式,用于排查定位线上问题以及实时运行情况. 搭建流程 安装虚拟输出设备:sud ...

随机推荐

  1. 鼠标滚动div固定浮动-加锚点

    页面:    <div class="pa">        <div class="w-95-sl bdl-2"><a>标 ...

  2. java中的foreach循环

    foreach语句是java5的新特征之一,在遍历数组.集合方面,foreach为开发人员提供了极大的方便. foreach语句是for语句的特殊简化版本,但是foreach语句并不能完全取代for语 ...

  3. java通用的方法整理

    判断字符串是否为空 public static boolean IsEmpty(String str){ if (str == null){ return true; } if ("&quo ...

  4. Mac上安装与更新Ruby,Rails运行环境

    Mac安装后就安装Xcode是个好主意,它将帮你安装好Unix环境需要的开发包,也可以独立安装command_line_tools_for_xcode 1.安装RVM RVM:Ruby Version ...

  5. SIT_服务器系统整合测试总结

    从2012年到2015年我的3年服务器测试,感觉一下子时间就已经飞逝而过,一直希望做个前三年的工作总结,现在用我那笨拙的笔触记录下自己的三年服务器测试生活! ***2012-2013 SE 这一年基本 ...

  6. 366. Find Leaves of Binary Tree

    Given a binary tree, collect a tree's nodes as if you were doing this: Collect and remove all leaves ...

  7. Python学习之变量

    Python 变量 python不用事先声明变量,赋值过程中就包含了变量声明和定义的过程 用“=”赋值,左边是变量名,右边是变量的值 数字 整数 int_var = 1 长整数 long_var = ...

  8. c++ float能到小数点后多少位

    float xiaoshu=0.0000000000000000000000000000000000000000000001; cout<<"xiaoshu"<& ...

  9. HDU 5884 (贪心)

    problem sort 题目大意 有n个数组,每个数组有a[i]个元素,每次可以将至多k个数组合并为一个数组,所花费代价为这些数组的元素和.给定代价上限,求将所有数组合并为1个数组的最小k. 解题分 ...

  10. 使用node-inspector对Node.js进行调试

    1.通过npm来安装node-inspector npm install -g node-inspector // -g 导入安装路径到环境变量 2.后在命令行中执行“node --debug app ...