Uses selenium 4.0.0a6 which works with python 3.6

This commit is contained in:
Yogesh Mahajan 2021-11-12 11:56:44 +05:30 committed by Akshay Joshi
parent 8bf178b0a3
commit 77931d2315
11 changed files with 47 additions and 45 deletions

View File

@ -12,6 +12,7 @@ import time
from selenium.webdriver import ActionChains from selenium.webdriver import ActionChains
from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from regression.python_test_utils import test_utils from regression.python_test_utils import test_utils
from regression.feature_utils.base_feature_test import BaseFeatureTest from regression.feature_utils.base_feature_test import BaseFeatureTest
from regression.feature_utils.locators import QueryToolLocators from regression.feature_utils.locators import QueryToolLocators
@ -62,7 +63,7 @@ class CopySelectedQueryResultsFeatureTest(BaseFeatureTest):
def paste_values_to_scratch_pad(self): def paste_values_to_scratch_pad(self):
self.page.driver.switch_to.default_content() self.page.driver.switch_to.default_content()
self.page.driver.switch_to.frame( self.page.driver.switch_to.frame(
self.page.driver.find_element_by_tag_name("iframe")) self.page.driver.find_element(By.TAG_NAME, "iframe"))
scratch_pad_ele = self.page.find_by_css_selector( scratch_pad_ele = self.page.find_by_css_selector(
QueryToolLocators.scratch_pad_css) QueryToolLocators.scratch_pad_css)
self.page.paste_values(scratch_pad_ele) self.page.paste_values(scratch_pad_ele)

View File

@ -137,7 +137,7 @@ class PGDataypeFeatureTest(BaseFeatureTest):
self.page.click_modal('Save') self.page.click_modal('Save')
self.page.wait_for_element_to_disappear( self.page.wait_for_element_to_disappear(
lambda driver: driver.find_element_by_css_selector(".ajs-modal") lambda driver: driver.find_element(By.CSS_SELECTOR, ".ajs-modal")
) )
time.sleep(0.5) time.sleep(0.5)
@ -200,8 +200,8 @@ class PGDataypeFeatureTest(BaseFeatureTest):
# For every sample data-type value, check the expected output. # For every sample data-type value, check the expected output.
cnt = 2 cnt = 2
cells = canvas.find_elements_by_css_selector( cells = canvas.find_elements(
QueryToolLocators.query_output_cells) By.CSS_SELECTOR, QueryToolLocators.query_output_cells)
# remove first element as it is row number. # remove first element as it is row number.
cells.pop(0) cells.pop(0)
for val, cell, datatype in zip( for val, cell, datatype in zip(

View File

@ -87,8 +87,8 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
(By.XPATH, (By.XPATH,
NavMenuLocators.process_watcher_alertfier)) NavMenuLocators.process_watcher_alertfier))
self.page.wait_for_element_to_disappear( self.page.wait_for_element_to_disappear(
lambda driver: driver.find_element_by_css_selector( lambda driver: driver.find_element(
".loading-logs"), 10) By.CSS_SELECTOR, ".loading-logs"), 10)
expected_backup_success_msg = "Successfully completed." expected_backup_success_msg = "Successfully completed."
self.assertEqual(status, expected_backup_success_msg) self.assertEqual(status, expected_backup_success_msg)
@ -133,8 +133,8 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
(By.XPATH, (By.XPATH,
NavMenuLocators.process_watcher_alertfier)) NavMenuLocators.process_watcher_alertfier))
self.page.wait_for_element_to_disappear( self.page.wait_for_element_to_disappear(
lambda driver: driver.find_element_by_css_selector( lambda driver: driver.find_element(
".loading-logs"), 10) By.CSS_SELECTOR, ".loading-logs"), 10)
self.assertEqual(status, expected_backup_success_msg) self.assertEqual(status, expected_backup_success_msg)
# Check for XSS in Restore details # Check for XSS in Restore details
@ -209,15 +209,16 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
try: try:
take_bckup.click() take_bckup.click()
if self.page.wait_for_element_to_disappear( if self.page.wait_for_element_to_disappear(
lambda driver: driver.find_element_by_name( lambda driver: driver.find_element(
By.NAME,
NavMenuLocators.backup_filename_txt_box_name)): NavMenuLocators.backup_filename_txt_box_name)):
click = False click = False
except Exception: except Exception:
pass pass
def initiate_restore(self): def initiate_restore(self):
tools_menu = self.driver.find_element_by_link_text( tools_menu = self.driver.find_element(
NavMenuLocators.tools_menu_link_text) By.LINK_TEXT, NavMenuLocators.tools_menu_link_text)
tools_menu.click() tools_menu.click()
restore_obj = self.page.find_by_css_selector( restore_obj = self.page.find_by_css_selector(
@ -239,7 +240,8 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
restore_btn.click() restore_btn.click()
self.page.wait_for_element_to_disappear( self.page.wait_for_element_to_disappear(
lambda driver: driver.find_element_by_css_selector( lambda driver: driver.find_element(
By.CSS_SELECTOR,
NavMenuLocators.restore_file_name_txt_box_name)) NavMenuLocators.restore_file_name_txt_box_name))
def _check_escaped_characters(self, source_code, string_to_find, source): def _check_escaped_characters(self, source_code, string_to_find, source):
@ -286,8 +288,8 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
default_binary_path = self.server['default_binary_paths'] default_binary_path = self.server['default_binary_paths']
if default_binary_path is not None: if default_binary_path is not None:
def get_server_version_string(): def get_server_version_string():
server_version = {130000: '13', 120000: '12', 110000: '11', server_version = {140000: '14', 130000: '13', 120000: '12',
100000: '10', 90600: '9.6'} 110000: '11', 100000: '10', 90600: '9.6'}
for k, v in server_version.items(): for k, v in server_version.items():
if k <= self.server_information['server_version']: if k <= self.server_information['server_version']:
return v return v
@ -317,5 +319,5 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
self.page.click_modal('Save') self.page.click_modal('Save')
self.page.wait_for_element_to_disappear( self.page.wait_for_element_to_disappear(
lambda driver: driver.find_element_by_css_selector(".ajs-modal") lambda driver: driver.find_element(By.CSS_SELECTOR, ".ajs-modal")
) )

View File

@ -81,8 +81,8 @@ class PGUtilitiesMaintenanceFeatureTest(BaseFeatureTest):
self._open_maintenance_dialogue() self._open_maintenance_dialogue()
self.page.click_modal('OK') self.page.click_modal('OK')
self.page.wait_for_element_to_disappear( self.page.wait_for_element_to_disappear(
lambda driver: driver.find_element_by_xpath( lambda driver: driver.find_element(
NavMenuLocators.maintenance_operation)) By.XPATH, NavMenuLocators.maintenance_operation))
# Wait for the backup status alertfier # Wait for the backup status alertfier
self.wait.until(EC.visibility_of_element_located( self.wait.until(EC.visibility_of_element_located(
@ -129,8 +129,8 @@ class PGUtilitiesMaintenanceFeatureTest(BaseFeatureTest):
(By.XPATH, (By.XPATH,
NavMenuLocators.process_watcher_alertfier)) NavMenuLocators.process_watcher_alertfier))
self.page.wait_for_element_to_disappear( self.page.wait_for_element_to_disappear(
lambda driver: driver.find_element_by_css_selector(".loading-logs") lambda driver: driver.find_element(
) By.CSS_SELECTOR, ".loading-logs"))
if status != "Successfully completed.": if status != "Successfully completed.":
self.assertEqual(status, "Successfully completed.") self.assertEqual(status, "Successfully completed.")

View File

@ -468,8 +468,9 @@ SELECT relname FROM pg_catalog.pg_class
canvas = self.wait.until(EC.presence_of_element_located( canvas = self.wait.until(EC.presence_of_element_located(
(By.CSS_SELECTOR, QueryToolLocators.query_output_canvas_css))) (By.CSS_SELECTOR, QueryToolLocators.query_output_canvas_css)))
el = canvas.find_elements_by_xpath( el = canvas.find_elements(
QueryToolLocators.output_column_data_xpath.format(table_name)) By.XPATH, QueryToolLocators.output_column_data_xpath.format(
table_name))
assert len(el) != 0, "Table '{}' is not created with auto " \ assert len(el) != 0, "Table '{}' is not created with auto " \
"commit enabled.".format(table_name) "commit enabled.".format(table_name)
@ -561,8 +562,9 @@ SELECT relname FROM pg_catalog.pg_class
canvas = self.wait.until(EC.presence_of_element_located( canvas = self.wait.until(EC.presence_of_element_located(
(By.CSS_SELECTOR, QueryToolLocators.query_output_canvas_css))) (By.CSS_SELECTOR, QueryToolLocators.query_output_canvas_css)))
el = canvas.find_elements_by_xpath( el = canvas.find_elements(
QueryToolLocators.output_column_data_xpath.format(table_name)) By.XPATH, QueryToolLocators.output_column_data_xpath.format(
table_name))
assert len(el) == 0, "Table '{}' created even after ROLLBACK due to " \ assert len(el) == 0, "Table '{}' created even after ROLLBACK due to " \
"sql error.".format(table_name) "sql error.".format(table_name)

View File

@ -56,8 +56,8 @@ class CopySQLFeatureTest(BaseFeatureTest):
% self.test_table_name, 10), "No data displayed in SQL tab") % self.test_table_name, 10), "No data displayed in SQL tab")
# Fetch the inner html & check for escaped characters # Fetch the inner html & check for escaped characters
source_code = self.driver.find_elements_by_xpath( source_code = self.driver.find_elements(
QueryToolLocators.code_mirror_data_xpath) By.XPATH, QueryToolLocators.code_mirror_data_xpath)
sql_query = '' sql_query = ''
for data in source_code: for data in source_code:
@ -74,10 +74,10 @@ class CopySQLFeatureTest(BaseFeatureTest):
self.driver.switch_to.default_content() self.driver.switch_to.default_content()
self.driver.switch_to.frame( self.driver.switch_to.frame(
self.driver.find_element_by_tag_name("iframe")) self.driver.find_element(By.TAG_NAME, "iframe"))
code_mirror = self.driver.find_elements_by_xpath( code_mirror = self.driver.find_elements(
QueryToolLocators.code_mirror_data_xpath) By.XPATH, QueryToolLocators.code_mirror_data_xpath)
query_tool_result = '' query_tool_result = ''
for data in code_mirror: for data in code_mirror:
query_tool_result += data.text query_tool_result += data.text

View File

@ -285,7 +285,7 @@ class CheckForXssFeatureTest(BaseFeatureTest):
self.page.find_by_css_selector(".slick-header-column") self.page.find_by_css_selector(".slick-header-column")
cells = self.driver. \ cells = self.driver. \
find_elements_by_css_selector(".slick-header-column") find_elements(By.CSS_SELECTOR, ".slick-header-column")
# remove first element as it is row number. # remove first element as it is row number.
# currently 4th col # currently 4th col
@ -315,9 +315,9 @@ class CheckForXssFeatureTest(BaseFeatureTest):
# Re-try logic # Re-try logic
try: try:
ActionChains(self.driver).move_to_element( ActionChains(self.driver).move_to_element(
self.driver.find_element_by_css_selector( self.driver.find_element(
'div.pgadmin-explain-container > svg > g > g > image' By.CSS_SELECTOR,
) 'div.pgadmin-explain-container > svg > g > g > image')
).click().perform() ).click().perform()
break break
except Exception: except Exception:
@ -331,7 +331,8 @@ class CheckForXssFeatureTest(BaseFeatureTest):
) )
raise raise
source_code = self.driver.find_element_by_css_selector( source_code = self.driver.find_element(
By.CSS_SELECTOR,
'.pgadmin-explain-details:not(.d-none)').get_attribute('innerHTML') '.pgadmin-explain-details:not(.d-none)').get_attribute('innerHTML')
self._check_escaped_characters( self._check_escaped_characters(

View File

@ -134,7 +134,7 @@ class CheckDebuggerForXssFeatureTest(BaseFeatureTest):
self._close_debugger() self._close_debugger()
def _close_debugger(self): def _close_debugger(self):
self.page.driver.switch_to_default_content() self.page.driver.switch_to.default_content()
self.page.click_element( self.page.click_element(
self.page.find_by_xpath( self.page.find_by_xpath(
"//*[@id='dockerContainer']/div/div[3]/div/div[2]/div[1]") "//*[@id='dockerContainer']/div/div[3]/div/div[2]/div[1]")

View File

@ -193,7 +193,7 @@ class PgadminPage:
" 'Remove Panel')]").click() " 'Remove Panel')]").click()
if prompt: if prompt:
self.driver.switch_to.frame( self.driver.switch_to.frame(
self.driver.find_elements_by_tag_name("iframe")[0]) self.driver.find_elements(By.TAG_NAME, "iframe")[0])
time.sleep(.5) time.sleep(.5)
self.click_element(self.find_by_xpath( self.click_element(self.find_by_xpath(
'//button[contains(@class, "ajs-button") and ' '//button[contains(@class, "ajs-button") and '
@ -241,8 +241,8 @@ class PgadminPage:
def check_execute_option(self, option): def check_execute_option(self, option):
""""This function will check auto commit or auto roll back based on """"This function will check auto commit or auto roll back based on
user input. If button is already checked, no action will be taken""" user input. If button is already checked, no action will be taken"""
query_options = self.driver.find_element_by_css_selector( query_options = self.driver.find_element(
QueryToolLocators.btn_query_dropdown) By.CSS_SELECTOR, QueryToolLocators.btn_query_dropdown)
expanded = query_options.get_attribute("aria-expanded") expanded = query_options.get_attribute("aria-expanded")
if expanded == "false": if expanded == "false":
query_options.click() query_options.click()
@ -250,8 +250,8 @@ class PgadminPage:
def update_execute_option_setting( def update_execute_option_setting(
css_selector_of_option_status, css_selector_of_option,): css_selector_of_option_status, css_selector_of_option,):
retry = 3 retry = 3
check_status = self.driver.find_element_by_css_selector( check_status = self.driver.find_element(
css_selector_of_option_status) By.CSS_SELECTOR, css_selector_of_option_status)
if 'visibility-hidden' in check_status.get_attribute('class'): if 'visibility-hidden' in check_status.get_attribute('class'):
while retry > 0: while retry > 0:
self.find_by_css_selector(css_selector_of_option).click() self.find_by_css_selector(css_selector_of_option).click()

View File

@ -1439,11 +1439,7 @@ def get_parallel_sequential_module_list(module_list):
""" """
# list of files consisting tests that needs to be # list of files consisting tests that needs to be
# executed sequentially # executed sequentially
sequential_tests_file = [ sequential_tests_file = []
'pgadmin.feature_tests.pg_utilities_backup_restore_test',
'pgadmin.feature_tests.pg_utilities_maintenance_test',
'pgadmin.feature_tests.keyboard_shortcut_test'
]
# list of tests can be executed in parallel # list of tests can be executed in parallel
parallel_tests = list(module_list) parallel_tests = list(module_list)

View File

@ -25,5 +25,5 @@ python-mimeparse==1.6.0
testscenarios==0.5.0 testscenarios==0.5.0
testtools==2.3.0 testtools==2.3.0
traceback2==1.4.0 traceback2==1.4.0
selenium==4.0.0 selenium==4.0.0a6
coverage==5.0.1 coverage==5.0.1