一、搭建基础环境
1. 新建python工程

设置pytest执行测试用例

2. 安装依赖包
pip install selenium
3. 下载浏览器驱动
-
存放目录
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方法,若能打开浏览器,则说明环境搭建成功
网友评论