1、斷言web
assert cur_title=='百度一下,你就知道1','title斷言失敗'ide
'title斷言失敗':自定義報錯ui
2、截圖url
# 調用截屏方法(路徑+截圖名稱)
driver.get_screenshot_as_file('../image/image.png')
from selenium import webdriver from time import sleep import os driver=webdriver.Chrome() # 最大化 driver.maximize_window() driver.get('https://www.baidu.com') cur_title=driver.title cur_url=driver.current_url print(cur_title) print(cur_url) assert cur_title=='百度一下,你就知道','title斷言失敗' try: assert cur_title=='百度一下,你就知道1','title斷言失敗' assert cur_url=='https://www.baidu.com/123' except: # 調用截屏方法 # driver.get_screenshot_as_file('../image/image.png') driver.get_screenshot_as_file('image.png') sleep(3) driver.quit()