zoukankan      html  css  js  c++  java
  • 基于python的selenium自动化测试环境搭建

    重新搭建环境,现补充web自动化测试环境的搭建。

    学习selenium python需要的工具:
      1、浏览器
      2、Python
      3、Selenium
      4、FireBug(Firefox)
      5、chromedriver、IEDriverServer、geckodriver
      6、IDE(Pycharm/Sublime/Eclipse等等)
    一、浏览器
    这里使用firefox浏览器
    二、Python环境搭建
    三、Selenium安装
    使用pip安装:pip install selenium
    四、驱动安装geckodriver/chromedriver/IEDriverServer(Windows环境下)
    win64地址:https://pan.baidu.com/s/1guRndaCjR4RBZNvbokE3GA
    五、驱动使用方法:
    使用方法:
    1、下载完成解压;
    2、将geckodriver放到python文件下
    3、添加到环境变量中(例如:G:Python36geckodriver.exe)
    Chrome:
    如果需要使用Chrome浏览器或者IE浏览器,则需要对应的驱动,chromedriver,chromedriver没有64位版本,32即可驱动:
    下载地址:https://npm.taobao.org/mirrors/chromedriver
    使用方法同geckodriver。
    IE:
    IEDriverServer,下面链接能够下载所有版本的selenium以及IEDriverServer,注意IEDriverServer区分32位/64位:
    下载地址:http://selenium-release.storage.googleapis.com/index.html
    使用方法同geckodriver。
    六、测试打开浏览器
    输入以下代码:
    # -*- coding: utf-8 -*-
    from selenium import webdriver
    driver = webdriver.Firefox()
    driver.get("https://www.baidu.com")

  • 相关阅读:
    Python 2 与 python 3的区别
    语法基础题
    Python运算符_ 2018-07-26
    Python 各种语句:2018-07-27
    解决在Python中使用Win32api报错的问题,No module named win32api
    在CenOS7.5里安装Redis
    下载Redis
    重置CentOS6.5的登录口令
    如何在CentOS里切换操作系统所用的语言,中英文切换
    在Ubuntu里安装Mysql5.7.23
  • 原文地址:https://www.cnblogs.com/LinxiHuang/p/9613737.html
Copyright © 2011-2022 走看看