-
整个测试过程只需要打开/关闭一次浏览器,大大缩短测试时间。
-
测试用例运行失败自动截图。
-
测试用例运行失败可以重跑。
-
测试数据参数化。
selenium: Web自动化测试库 https://pypi.python.org/pypi/selenium
pytest: 单元测试框架 https://pypi.python.org/pypi/pytest
pytest-html: 生成html测试报告 https://pypi.python.org/pypi/pytest-html
pytest-rerunfailures: 失败重跑 https://pypi.python.org/pypi/pytest-rerunfailures
pip install -r requirements.txt
@pytest.mark.parametrize(
"name, searchkey",
[("1", "Selenium"),
("2", "pytest文档"),
])
def test_baidu_search(name, searchkey, browser):
bd = BaiduPage(browser)
bd.open()
bd.search_input(searchkey)
bd.search_button()
sleep(1)
title = bd.search_title()
assert title == searchkey+"_百度搜索"