1.实际测试过程当中,经常要对比实际结果与指望结果是否一致。
2.若是实际结果与指望结果不一致则被认为bugpython
selenium普遍应用于B/S架构,如何经过selenium来验证测试结果的正确性呢。web
#****************** # 获取验证信息,操做某页面后,确认进入的是指望结果 #****************** from selenium import webdriver from time import sleep driver = webdriver.Firefox() driver.get("http://www.baidu.com") print("===========The baidu Page===============") First_Title = driver.title print("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.title print("The Second page title is:%s" % Second_Title) Expect_Title = "hao123_上网从这里开始" if Second_Title == Expect_Title: print(True) else: print(False) driver.quit()
推广下个人博客专栏,目前选定了一个主题《从零学Selenium自动化测试框架》请添加连接描述,让咱们从代码撸起,一步步实现Web自动化测试框架架构
该专题会从零带你搭建一个可用的自动化测试框架(基于python+selenium)框架
前提:你要掌握了python与selenium基础哦。要不你看不懂的。ide