How to use delete_downloaded_file_if_present method in SeleniumBase

Best Python code snippet using SeleniumBase

test_shadow_dom.py

Source:test_shadow_dom.py Github

copy

Full Screen

...10 pkg_header = self.get_text("h1.package-header__name").strip()11 pkg_name = pkg_header.replace(" ", "-")12 tar_file = pkg_name + ".tar.gz"13 tar_selector = 'div#files a[href$="%s"]' % tar_file14 self.delete_downloaded_file_if_present(tar_file, browser=True)15 self.click(tar_selector)16 return tar_file17 def test_shadow_dom(self):18 if self.browser != "chrome":19 self.open("data:,")20 print("\n This test is for Google Chrome only!")21 self.skip("This test is for Google Chrome only!")22 if self.headless:23 self.open("data:,")24 print("\n This test doesn't run in headless mode!")25 self.skip("This test doesn't run in headless mode!")26 # Download Python package files from PyPI27 file_name_1 = self.download_tar_file_from_pypi("sbase")28 file_name_2 = self.download_tar_file_from_pypi("seleniumbase")29 self.assert_downloaded_file(file_name_1, browser=True)30 self.assert_downloaded_file(file_name_2, browser=True)31 # Navigate to the Chrome downloads page.32 self.open("chrome://downloads/")33 # Shadow DOM selectors34 search_icon = (35 "downloads-manager::shadow downloads-toolbar::shadow"36 " cr-toolbar::shadow cr-toolbar-search-field::shadow"37 " cr-icon-button"38 )39 search_input = (40 "downloads-manager::shadow downloads-toolbar::shadow"41 " cr-toolbar::shadow cr-toolbar-search-field::shadow"42 " #searchInput"43 )44 clear_search_icon = (45 "downloads-manager::shadow downloads-toolbar::shadow"46 " cr-toolbar::shadow cr-toolbar-search-field::shadow"47 " #clearSearch"48 )49 file_link = (50 "downloads-manager::shadow #downloadsList"51 " downloads-item::shadow #file-link"52 )53 remove_button = (54 "downloads-manager::shadow #downloadsList"55 " downloads-item::shadow #remove"56 )57 no_downloads_area = "downloads-manager::shadow #no-downloads"58 self.assert_element(search_icon)59 self.type(search_input, "sbase")60 self.assert_text(file_name_1, file_link)61 print("\n Download 1: %s" % self.get_text(file_link))62 self.type(search_input, "seleniumbase")63 self.assert_text(file_name_2, file_link)64 print(" Download 2: %s" % self.get_text(file_link))65 self.click(clear_search_icon)66 self.type(search_input, "fake-file.zzz")67 self.assert_text("No search results found", no_downloads_area)68 self.click(clear_search_icon)69 self.assert_element(remove_button)70 # Delete the downloaded files from the [Downloads Folder]71 self.delete_downloaded_file_if_present(file_name_1, browser=True)...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run SeleniumBase automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful