本文共 1073 字,大约阅读时间需要 3 分钟。
selenium广泛应用于B/S架构,如何通过selenium来验证测试结果的正确性呢。
#******************# 获取验证信息,操作某页面后,确认进入的是期望结果#******************from selenium import webdriverfrom time import sleepdriver = webdriver.Firefox()driver.get("http://www.baidu.com")print("===========The baidu Page===============")First_Title = driver.titleprint("The first page title is:%s" % First_Title)print("===========The hao123 Page===============")driver.find_element_by_xpath("//a[@name='tj_trhao123']").click()Second_Title = driver.titleprint("The Second page title is:%s" % Second_Title)Expect_Title = "hao123_上网从这里开始"if Second_Title == Expect_Title: print(True)else: print(False)driver.quit()
如果你想系统学习selenium,可以通过如途径哦…
推广下我的博客专栏,目前选定了一个主题《从零学Selenium自动化测试框架》让我们从代码撸起,一步步实现Web自动化测试框架该专题会从零带你搭建一个可用的自动化测试框架(基于python+selenium)前提:你要掌握了python与selenium基础哦。要不你看不懂的。
领取更多资料微信搜索【程序员二黑】,免费视频教程,面试题等你来拿
转载地址:http://mvhn.baihongyu.com/