Fixed feature tests failing due to selenium upgrade to 4.10.0.

This commit is contained in:
Yogesh Mahajan 2023-06-19 11:43:28 +05:30 committed by GitHub
parent b8377be1b5
commit eef295f9d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 26 deletions

View File

@ -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.")

View File

@ -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

View File

@ -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()