selenium webdriver启动Chrome浏览器后无法输入网址的解决办法
通过selenium webdriver启动Chrome浏览器,脚本如下:
from selenium import webdriver
browser = webdriver.Chrome()
browser.get("http://www.baidu.com")
browser.find_element_by_id("kw").send_keys("selenium")
browser.find_element_by_id("su").click()
browser.quit()
浏览器启动成功,但是地址无法输入,报错:ConnectionResetError: [WinError 10054] 远程主机强迫关闭了一个现有的连接。
浏览器显示如下:

selenium版本:3.0.1
python版本3.5
Chrome版本:54.0.2840.99 m
修改以下部分脚本
option= webdriver.ChromeOptions()
option.add_argument('--user-data-dir=C:\\Users\FF\AppData\Local\Google\Chrome\\User Data') #设置成用户自己的数据目录
browser = webdriver.Chrome(chrome_options=option)
修改后重新运行,报错:selenium.common.exceptions.WebDriverException: Message: unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"3624.1","isDefault":true},"id":1,"name":"","origin":"://"}
(Session info: chrome=54.0.2840.99)
(Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64)
表示chrome浏览器版本为54.0.2840.99,但是chromedriver版本为2.9.248315。版本不兼容
网上找了遇到相同问题的解决办法 http://blog.csdn.net/u012246342/article/details/52860949
下载v2.24版本的chromedriver.exe替换原有的chromedriver.exe(下载地址: http://chromedriver.storage.googleapis.com/index.html?path=2.24/ )
重新运行脚本,第一次运行较慢,最终超时失败,第二次运行成功!!
下面是关于加载Chrome配置的方法(网上copy的,保存留用):
一、加载所有Chrome配置
用Chrome地址栏输入chrome://version/,查看自己的“个人资料路径”,然后在浏览器启动时,调用这个配置文件,代码如下:
#coding=utf-8
from selenium import webdriver
option = webdriver.ChromeOptions()
option.add_argument('--user-data-dir=C:\Users\Administrator\AppData\Local\Google\Chrome\User Data') #设置成用户自己的数据目录
driver = webdriver.Chrome(chrome_options=option)
二、修改浏览器的User-Agent来伪装你的浏览器访问手机m站
#coding=utf-8
from selenium import webdriver
option = webdriver.ChromeOptions()
option.add_argument('--user-agent=iphone')
driver = webdriver.Chrome(chrome_options=option)
driver.get('http://www.taobao.com/')
三、浏览器启动时安装crx扩展
#coding=utf-8
from selenium import webdriver
option = webdriver.ChromeOptions()
option.add_extension('d:\crx\AdBlock_v2.17.crx') #自己下载的crx路径
driver = webdriver.Chrome(chrome_options=option)
driver.get('http://www.taobao.com/')
selenium webdriver启动Chrome浏览器后无法输入网址的解决办法的更多相关文章
- selenium webdriver 启动三大浏览器Firefox,Chrome,IE
selenium webdriver 启动三大浏览器Firefox,Chrome,IE 1.安装selenium 在联网的情况下,在Windows命令行(cmd)输入pip install selen ...
- selenium webdriver启动IE浏览器失败的解决办法
通过selenium webdriver启动IE浏览器失败,报错:selenium.common.exceptions.WebDriverException: Message: Unexpected ...
- ChromeDriver启动Chrome浏览器后,地址栏只显示data;——chromeDriver版本不对
ChromeDriver启动Chrome浏览器后,地址栏只显示data; 错误原因: chromeDriver版本不对,不同版本的chromeDriver对应不同版本的chrome浏览器 chrome ...
- 【Selenium专题】WebDriver启动Chrome浏览器(一)
selenium操作chrome浏览器需要有ChromeDriver驱动来协助.一.什么是ChromeDriver?ChromeDriver是Chromium team开发维护的,它是实现WebDri ...
- Webdriver启动Firefox浏览器后,页面显示空白
在使用pycharm码代码时编译总是出错,后来验证发现浏览器启动后出现问题.白白耗了我2个小时.我把我的解决方案写出来,希望对大家有帮助. 1.现象:起初安装的时候总是能正常运行,有一天突然发现Web ...
- 【Selenium专题】WebDriver启动Chrome浏览器(二)
官方API Constructor Summary ChromeDriver() Creates a new ChromeDriver using the default server configu ...
- jenkins里跑selenium webdriver,Chrome浏览器不能打开&&unknown error: unable to discover open pages
在windows的cmd里面执行 “python test.py”,毫无问题,浏览器正常打开,测试结果也正常. 问题: 但如果是在jenkins里,选择 “execute windows batch ...
- Selenium webdriver 操作chrome 浏览器
Step1: 下载chromedriver. 下载路径: http://chromedriver.storage.googleapis.com/index.html 选择一个合适的下载即可.我下载的是 ...
- selenium webdriver 使用Chrome 浏览器
首先需要有ChromeDriver驱动来协助.ChromeDriver是实现WebDriver有线协议的一个单独的服务.ChromeDriver通过chrome的自动代理框架控制浏览器,ChromeD ...
随机推荐
- Invalid project description overlaps the location of another project [android]
解决办法: 1.将工程放到其他目录下,然后执行Android工程的导入,导入时可以选择“Copy projects into workspace”: 2.不用Android工程导入,而用普通的工程导入 ...
- in_array 判断问题的疑惑解决。
面试题中有一条是关于in_array判断的,题目如下: 如何大家没有深入了解in_array的类型判断过程,而是根据经验来选择,肯定很多人也是是选择了D答案的,具体的原因我也是从牛人的博客里面得到答案 ...
- ExtJs4 学习3 combox自动加载的例子
Ext.onReady(function() { delivery_datas = [{ "Id" : "1", "Name" : &q ...
- actionscript sendToURL请求url,传递http_referer分浏览器统计
IE全版本都不传递referer,但会在header中传递X_FLASH_VERSION,例如:"HTTP_X_FLASH_VERSION":"13,0,0,182&qu ...
- python的min()函数也可用于比较tuple
python的min()函数也可用于比较tuple >>> a = (2,'asv','dfg') >>> b = (3,'gsg','weg') >&g ...
- 从NIB中加载VIEW
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ChatMoreView" owner:nil options:nil]; ...
- Ubiquitous Religions(并查集)
Description There are so many different religions in the world today that it is difficult to keep tr ...
- ASP.NET Routing
ASP.NET Routing Other Versions ASP.NET routing enables you to use URLs that do not have to map to ...
- bzoj3230
以前觉得这题好难,现在觉得这题还是挺简单首先看到类似LCP问题不难想到后缀数组吧前后的相似需要我们分别做一个后缀数组和“前缀数组”(就是把字符串反向然后跑后缀数组)这道题的难点就在于如何确定子串是什么 ...
- 嵌入式设备web服务器比较
目录(?)[-] Boa Thttpd Mini_httpd Shttpd Lighttpd Goahead AppWeb Apache 开发语言和开发工具 结论 备注 现在在嵌入式设备中所使用的 ...