selenium与firefox版本不对应,提示“The browser appears to have exited”错误

pip了selenium包后,使用selenium开始webdriver打开firefox浏览器,发现报错

'''

raise WebDriverException("The browser appears to have exited "
selenium.common.exceptions.WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.

'''

查了下资料,发现极大可能是selenium版本跟firefox版本不匹配导致——在我们连接之前,似乎浏览器已经退出(The browser appears to have exited before we could connect.)

解决方法:

1、更改firefox浏览器版本

2、更改selenium版本

 

我选择的更改了firefox浏览器版本,我的selenium版本为2.48.0,根据网络上的信息,可以使用40左右的版本,下载了个38.0的版本,跑了下面的代码正常,OK,收工!

from selenium import webdriver
from time import sleep

driver=webdriver.Firefox()
driver.get('http://www.baidu.com')
sleep(3)
driver.quit()

 

贴个firefox版本下载地址

http://ftp.mozilla.org/pub/firefox/releases/

更改selenium的版本

使用命令"pip install selenium==xxx"就行

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值