zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    Begin Again
    hadoop集群启动start-dfs.sh有节点datanode启动不了问题
    centos中python更新后yum不可用问题
    浏览器无法访问hdfs界面问题
    数据的统计分析与描述
    插值与拟合
    层次分析法
    四种规划-数学建模
    Hive深入使用
    Hadoop-Hive
  • 原文地址:https://www.cnblogs.com/studyddup0212/p/9028496.html
Copyright © 2011-2022 走看看