UI自动化使用断言示例1

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()

 

你可能感兴趣的:(chrome,selenium)