UI自動化使用斷言示例1

幽影冥狐發表於2020-12-26
from selenium import webdriver
import time



# driver = Chrome("C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe")
# driver.get('https://www.baidu.com')


driver = webdriver.Chrome()  # 開啟谷歌瀏覽器
driver.get('http://cms.ipinyue.com/#/login')  # 訪問CMS後臺網址

try:
    # assert u"百度一我" in driver.title
    # DF =driver.find_element_by_xpath('//*[@id="app"]/div/div/div/div/div/div[2]/form/div[1]/div/div[1]/input')
    assert u"使用者名稱" in driver.page_source
    print("Assertion test pass")
except Exception as e:
    print("Assertion test fail",format(e))
# print(driver.title)
    print(driver.title)
time.sleep(5)
# driver.quit()

 

相關文章