Best Python code snippet using SeleniumBase
test_save_screenshots.py
Source:test_save_screenshots.py
...6 # "./downloaded_files" is a special SeleniumBase folder for downloads7 self.save_screenshot("demo_page.png", folder="./downloaded_files")8 self.assert_downloaded_file("demo_page.png")9 print('\n"%s/%s" was saved!' % ("downloaded_files", "demo_page.png"))10 def test_save_screenshot_to_logs(self):11 self.open("https://seleniumbase.io/demo_page")12 self.save_screenshot_to_logs()13 # "self.log_path" is the absolute path to the "./latest_logs" folder.14 # Each test that generates log files will create a subfolder in there15 test_logpath = os.path.join(self.log_path, self.test_id)16 expected_screenshot = os.path.join(test_logpath, "_1_screenshot.png")17 self.assert_true(os.path.exists(expected_screenshot))18 print('\n"%s" was saved!' % (expected_screenshot))19 self.open("https://seleniumbase.io/tinymce/")20 self.save_screenshot_to_logs()21 expected_screenshot = os.path.join(test_logpath, "_2_screenshot.png")22 self.assert_true(os.path.exists(expected_screenshot))23 print('"%s" was saved!' % (expected_screenshot))24 self.open("https://seleniumbase.io/error_page/")25 self.save_screenshot_to_logs("error_page")26 expected_screenshot = os.path.join(test_logpath, "_3_error_page.png")27 self.assert_true(os.path.exists(expected_screenshot))28 print('"%s" was saved!' % (expected_screenshot))29 self.open("https://seleniumbase.io/devices/")30 self.save_screenshot_to_logs("devices")31 expected_screenshot = os.path.join(test_logpath, "_4_devices.png")32 self.assert_true(os.path.exists(expected_screenshot))...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!