准备工作:
1、下载Python
2、pip下载pytest-selenium
代码:
from selenium.webdriver.common.by import By
def test_baidu_so_get_value(selenium):
selenium.get('http://www.baidu.com/')
kw = selenium.find_element(By.ID, 'kw')
kw.send_keys('NBA')
assert kw.get_attribute('value') == 'NBA'
命令行执行:
pytest TestCase/test_case.py --driver Chrome --html=report/result.html
============================================== test session starts ==================================