From eef295f9d83d433224cd2fbab943ebfbf17f2a2a Mon Sep 17 00:00:00 2001 From: Yogesh Mahajan Date: Mon, 19 Jun 2023 11:43:28 +0530 Subject: [PATCH] Fixed feature tests failing due to selenium upgrade to 4.10.0. --- .../python_test_utils/test_utils.py | 42 +++++++++---------- web/regression/requirements.txt | 2 +- web/regression/runtests.py | 6 ++- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/web/regression/python_test_utils/test_utils.py b/web/regression/python_test_utils/test_utils.py index d0f35e131..c08183e52 100644 --- a/web/regression/python_test_utils/test_utils.py +++ b/web/regression/python_test_utils/test_utils.py @@ -26,7 +26,7 @@ from selenium.common.exceptions import WebDriverException from urllib.request import urlopen import json from selenium import webdriver -from selenium.webdriver.chrome.options import Options +from selenium.webdriver.firefox.options import Options as FirefoxOptions from selenium.webdriver.support import expected_conditions as ec import selenium.common.exceptions @@ -35,7 +35,7 @@ import regression from regression import test_setup from pgadmin.utils.preferences import Preferences -from pgadmin.utils.constants import BINARY_PATHS, PSYCOPG3 +from pgadmin.utils.constants import BINARY_PATHS from pgadmin.utils import set_binary_path from functools import wraps @@ -1410,38 +1410,34 @@ def get_remote_webdriver(hub_url, browser, browser_ver, test_name, url_client): test_name = time.strftime("%m_%d_%y_%H_%M_%S_", time.localtime()) + \ test_name.replace(' ', '_') + '_' + browser + browser_ver driver_local = None - desired_capabilities = { - "browserVersion": browser_ver, - "selenoid:options": { - "enableVNC": True, - "enableVideo": True, - "enableLog": True, - "videoName": test_name + ".mp4", - "logName": test_name + ".log", - "name": test_name, - "timeZone": "Asia/Kolkata", - "sessionTimeout": "180s" - } + selenoid_options = { + "enableVNC": True, + "enableVideo": True, + "enableLog": True, + "videoName": test_name + ".mp4", + "logName": test_name + ".log", + "name": test_name, + "timeZone": "Asia/Kolkata", + "sessionTimeout": "180s" } if browser == 'firefox': + options = FirefoxOptions() + options.browser_version = browser_ver profile = webdriver.FirefoxProfile() profile.set_preference("dom.disable_beforeunload", True) - desired_capabilities["browserName"] = "firefox" - desired_capabilities["requireWindowFocus"] = True - desired_capabilities["enablePersistentHover"] = False + options.profile = profile driver_local = webdriver.Remote( - command_executor=hub_url, - desired_capabilities=desired_capabilities, browser_profile=profile) + command_executor=hub_url, options=options) elif browser == 'chrome': - options = Options() + options = webdriver.ChromeOptions() options.add_argument("--window-size=1280,1024") options.add_argument( '--unsafely-treat-insecure-origin-as-secure=' + url_client) - desired_capabilities["browserName"] = "chrome" + options.browser_version = browser_ver + options.set_capability("selenoid:options", selenoid_options) driver_local = webdriver.Remote( - command_executor=hub_url, - desired_capabilities=desired_capabilities, options=options) + command_executor=hub_url, options=options) else: print("Specified browser does not exist.") diff --git a/web/regression/requirements.txt b/web/regression/requirements.txt index 44d1abdb1..b8e09021e 100644 --- a/web/regression/requirements.txt +++ b/web/regression/requirements.txt @@ -25,5 +25,5 @@ python-mimeparse==1.6.0 testscenarios==0.5.0 testtools==2.6.0 traceback2==1.4.0 -selenium==4.9.1 +selenium==4.10.0 coverage==7.2.7 diff --git a/web/regression/runtests.py b/web/regression/runtests.py index db58d2a61..001cdf98c 100644 --- a/web/regression/runtests.py +++ b/web/regression/runtests.py @@ -23,6 +23,7 @@ import threading import time import unittest import asyncio +from selenium.webdriver.firefox.options import Options as FirefoxOptions if sys.platform == "win32": asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) @@ -283,13 +284,14 @@ def setup_webdriver_specification(arguments): 'default_browser'].lower() if default_browser == 'firefox': + options = FirefoxOptions() cap = DesiredCapabilities.FIREFOX cap['requireWindowFocus'] = True cap['enablePersistentHover'] = False profile = webdriver.FirefoxProfile() profile.set_preference("dom.disable_beforeunload", True) - driver_local = webdriver.Firefox(capabilities=cap, - firefox_profile=profile) + options.profile = profile + driver_local = webdriver.Firefox(options=options) driver_local.implicitly_wait(1) else: options = Options()