首页 > 其他 > 详细

selenium测试-open chrome

时间:2018-05-12 14:08:54      阅读:131      评论:0      收藏:0      [点我收藏+]

通过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

selenium测试-open chrome

原文:https://www.cnblogs.com/studyddup0212/p/9028496.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!