from selenium import webdriver
import pytest
index_list = ['首页', '通讯录', '收件箱']
# fixture
@pytest.fixture(scope='module', autouse=True)
def before_webtest():
print('\n--------执行初始化-------------')
print('登陆163邮箱')
global wd
wd = webdriver.Chrome()
# wd = webdriver.Ie()
wd.implicitly_wait(5)
wd.get('https://email.163.com/')
# swift_to属性切换frame
wd.switch_to.frame(wd.find_element_by_xpath('//div[@id="urs163Area"]//iframe'))
ele = wd.find_element_by_xpath('//input[@name="email"]')
ele.clear()
ele.send_keys('****')
ele = wd.find_element_by_xpath('//input[@name="password"]')
ele.clear()
ele.send_keys('******')
wd.find_element_by_xpath('//a[@id="dologin"]').click()
# 登陆成功进入新页面
print(&#
pytest-fixture 环境初始化与清除
最新推荐文章于 2024-07-30 20:14:05 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)