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