UI自动化-01-搭建环境-极简

2019-08-04  本文已影响0人  果芽软件

一、搭建基础环境

1. 新建python工程

image.png

设置pytest执行测试用例


image.png

2. 安装依赖包

pip install selenium

3. 下载浏览器驱动

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

  2. 存放目录


    image.png

二、打开浏览器

注意:是大写的Chrome类,而不是小写的chrome属性

import time
from selenium import webdriver

def test_open():
    # 通过驱动程序启动chrome浏览器
    driver = webdriver.Chrome('D:/softwaredate/pythondate/ui-test-04/chrome_driver/chromedriver.exe')
    # 浏览器最大化
    driver.maximize_window()
    time.sleep(2)

执行test_open方法,若能打开浏览器,则说明环境搭建成功

上一篇 下一篇

猜你喜欢

热点阅读