Window Screenshot
- Purpose: When the script execution error of the current window screenshot
- 方法:get_screenshot_as_file()
-
# Open the Baidu home page, search for "selenium", a screenshot is complete, save the result to the D: /test.png from the Selenium Import webdriver Import Time Driver = webdriver.Firefox () driver.maximize_window () driver.get ( " HTTPS : //www.baidu.com " ) driver.find_element_by_id ( ' kW ' ) .send_keys ( ' Selenium ' ) driver.find_element_by_id ( ' SU ' ) .click () the time.sleep ( 2 ) driver.get_screenshot_as_file ( ' D: /test.png ' ) #Screenshot and save the time.sleep (2 ) driver.quit ()