From 0b663b30c1fb8db2ec8b42aed84012debdc71e1b Mon Sep 17 00:00:00 2001 From: Viet Nguyen Duc Date: Fri, 8 Dec 2023 23:17:18 +0700 Subject: [PATCH] Update to Selenium 4.16.1 [deploy] (#2055) --- Makefile | 2 +- tests/SeleniumTests/__init__.py | 34 +++++++++++++++++++++------------ 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 8209db4c3..5df2eb27e 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ NAME := $(or $(NAME),$(NAME),selenium) CURRENT_DATE := $(shell date '+%Y%m%d') BUILD_DATE := $(or $(BUILD_DATE),$(BUILD_DATE),$(CURRENT_DATE)) -VERSION := $(or $(VERSION),$(VERSION),4.16.0) +VERSION := $(or $(VERSION),$(VERSION),4.16.1) BASE_VERSION := $(or $(BASE_VERSION),$(BASE_VERSION),4.16.1) BASE_RELEASE := $(or $(BASE_RELEASE),$(BASE_RELEASE),selenium-4.16.0) TAG_VERSION := $(VERSION)-$(BUILD_DATE) diff --git a/tests/SeleniumTests/__init__.py b/tests/SeleniumTests/__init__.py index 263cc11ca..fa95acefa 100644 --- a/tests/SeleniumTests/__init__.py +++ b/tests/SeleniumTests/__init__.py @@ -67,18 +67,22 @@ def test_play_video(self): def test_download_file(self): driver = self.driver - driver.get('https://demoqa.com/upload-download') - file_name = 'sampleFile.jpeg' - wait = WebDriverWait(driver, 30) - file_link = wait.until( - EC.element_to_be_clickable((By.XPATH, f'//*[@download="{file_name}"]')) - ) - file_link.click() - wait.until( - lambda d: str(d.get_downloadable_files()[0]).endswith(file_name) - ) - time.sleep(5) - self.assertTrue(str(driver.get_downloadable_files()[0]).endswith(file_name)) + driver.get('https://the-internet.herokuapp.com/download') + file_name = 'some-file.txt' + is_continue = True + try: + wait = WebDriverWait(driver, 30) + file_link = wait.until( + EC.element_to_be_clickable((By.LINK_TEXT, file_name)) + ) + except: + is_continue = False + if is_continue: + file_link.click() + wait.until( + lambda d: str(d.get_downloadable_files()[0]).endswith(file_name) + ) + self.assertTrue(str(driver.get_downloadable_files()[0]).endswith(file_name)) def tearDown(self): self.driver.quit() @@ -88,6 +92,7 @@ class ChromeTests(SeleniumGenericTests): def setUp(self): options = ChromeOptions() options.enable_downloads = True + options.add_argument('disable-features=DownloadBubble,DownloadBubbleV2') self.driver = webdriver.Remote( options=options, command_executor="http://%s:%s" % (SELENIUM_GRID_HOST,SELENIUM_GRID_PORT) @@ -97,6 +102,7 @@ class EdgeTests(SeleniumGenericTests): def setUp(self): options = EdgeOptions() options.enable_downloads = True + options.add_argument('disable-features=DownloadBubble,DownloadBubbleV2') self.driver = webdriver.Remote( options=options, command_executor="http://%s:%s" % (SELENIUM_GRID_HOST,SELENIUM_GRID_PORT) @@ -105,7 +111,11 @@ def setUp(self): class FirefoxTests(SeleniumGenericTests): def setUp(self): + profile = webdriver.FirefoxProfile() + profile.set_preference("browser.download.manager.showWhenStarting", False) + profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "*/*") options = FirefoxOptions() + options.profile = profile options.enable_downloads = True self.driver = webdriver.Remote( options=options,