测试平台开发:(18)自动化测试脚本工具化 1

上一篇:测试平台开发:(17)新增测试用例功能示例_新增用户信息测试用例_要开朗的spookypop的博客-CSDN博客

先看看我们最熟悉不过的自动化测试脚本,用python + selenium编写:

service = ChromeService(executable_path=ChromeDriverManager().install())
driver = webdriver.Chrome(service=service)
driver.get('http://www.softwarebox.club/pages/OnlineTools/AutoLearn')
driver.implicitly_wait(3)
driver.maximize_window()
driver.find_element(By.ID, 'username').send_keys('小明')
driver.find_element(By.ID, 'password').send_keys('123456Xm')
# 通过XPath定位登录按钮,并点击
driver.find_element(By.XPATH, '//*[@id="contentmain"]/section/div[2]/form/button[1]').click()
time.sleep(3)
assert driver.current_url == 'http://www.softwarebox.club/

你可能感兴趣的:(测试工具,自动化,selenium,python)