First, the assertion
Second, screenshots
Method # call screen shot (path + theme name)
driver.get_screenshot_as_file ( '../ Image / image.png')
from Selenium Import the webdriver from Time Import SLEEP Import OS Driver = webdriver.Chrome () # maximize driver.maximize_window () driver.get ( ' https://www.baidu.com ' ) cur_title = driver.title cur_url = Driver. current_url Print (cur_title) Print (cur_url) the assert cur_title == ' Baidu, you know ' , ' title assertion failed ' the try : the assert== cur_title ' Baidu, you know ' , ' title Assertion failed ' the Assert cur_url == ' https://www.baidu.com/123 ' the except : # invoke method screenshots driver.get_screenshot_as_file ( ' ../image/ image.png ' )