Best Python code snippet using SeleniumBase
test_download_files.py
Source:test_download_files.py
1import math2from seleniumbase import BaseCase3class DownloadTests(BaseCase):4 def test_download_chromedriver_notes(self):5 self.open("https://chromedriver.chromium.org/downloads")6 notes_file = "notes.txt"7 notes_link = (8 "https://chromedriver.storage.googleapis.com"9 "/101.0.4951.41/%s" % notes_file10 )11 self.download_file(notes_link)12 self.assert_downloaded_file(notes_file)13 notes_path = self.get_path_of_downloaded_file(notes_file)14 with open(notes_path, "r") as f:15 notes_data = f.read()16 self.assert_true(len(notes_data) > 100) # Verify file not empty17 text = "Switching to nested frame fails with chrome/chromedriver 100"18 self.assert_true(text in notes_data) # Verify file has expected data...
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!!