selenium测试-open chrome

通过selenium来打开浏览器测试之前,需要确认本地已安装相应的webdriver,本例以chrome为例。

1. 查看本地chrome版本,以此确认需要安装的webdriver版本

查看chrome的help信息,确认chrome版本是v66

 

2. 下载相应的webdriver

下载地址:http://chromedriver.storage.googleapis.com/index.html

每个版本的文件夹中都有note信息,通过note信息来确认下载匹配chorme版本的webdriver。本地需要下载的是V2.38。

 

3. 将webdriver添加至环境变量

新建目录:c:\driver,并将下载的chrome的webdriver存储于此

将c:\driver添加至环境变量。

 

4. 编写程序测试open browser

from selenium import webdriver

driver = webdriver.Chrome()
driver.get('http://www.baidu.com')
print(driver.title)

driver.quit()

百度通过chrome打开成功。

 

5. 测试过程中遇到的问题

程序运行后报错:

ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host。

原因是chrome的webdriver驱动版本与chrome版本不匹配,下载正确的webdriver版本2.38,测试ok。

 

6. 相关资料阅读:

http://www.testclass.net/selenium_python/selenium3-browser-driver/

 https://blog.csdn.net/javalixy/article/details/77874715

转载于:https://www.cnblogs.com/studyddup0212/p/9028496.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值