mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-25 10:10:19 -06:00
Uses selenium 4.0.0a6 which works with python 3.6
This commit is contained in:
parent
8bf178b0a3
commit
77931d2315
@ -12,6 +12,7 @@ import time
|
||||
|
||||
from selenium.webdriver import ActionChains
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
from selenium.webdriver.common.by import By
|
||||
from regression.python_test_utils import test_utils
|
||||
from regression.feature_utils.base_feature_test import BaseFeatureTest
|
||||
from regression.feature_utils.locators import QueryToolLocators
|
||||
@ -62,7 +63,7 @@ class CopySelectedQueryResultsFeatureTest(BaseFeatureTest):
|
||||
def paste_values_to_scratch_pad(self):
|
||||
self.page.driver.switch_to.default_content()
|
||||
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(
|
||||
QueryToolLocators.scratch_pad_css)
|
||||
self.page.paste_values(scratch_pad_ele)
|
||||
|
@ -137,7 +137,7 @@ class PGDataypeFeatureTest(BaseFeatureTest):
|
||||
self.page.click_modal('Save')
|
||||
|
||||
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)
|
||||
|
||||
@ -200,8 +200,8 @@ class PGDataypeFeatureTest(BaseFeatureTest):
|
||||
|
||||
# For every sample data-type value, check the expected output.
|
||||
cnt = 2
|
||||
cells = canvas.find_elements_by_css_selector(
|
||||
QueryToolLocators.query_output_cells)
|
||||
cells = canvas.find_elements(
|
||||
By.CSS_SELECTOR, QueryToolLocators.query_output_cells)
|
||||
# remove first element as it is row number.
|
||||
cells.pop(0)
|
||||
for val, cell, datatype in zip(
|
||||
|
@ -87,8 +87,8 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
|
||||
(By.XPATH,
|
||||
NavMenuLocators.process_watcher_alertfier))
|
||||
self.page.wait_for_element_to_disappear(
|
||||
lambda driver: driver.find_element_by_css_selector(
|
||||
".loading-logs"), 10)
|
||||
lambda driver: driver.find_element(
|
||||
By.CSS_SELECTOR, ".loading-logs"), 10)
|
||||
|
||||
expected_backup_success_msg = "Successfully completed."
|
||||
self.assertEqual(status, expected_backup_success_msg)
|
||||
@ -133,8 +133,8 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
|
||||
(By.XPATH,
|
||||
NavMenuLocators.process_watcher_alertfier))
|
||||
self.page.wait_for_element_to_disappear(
|
||||
lambda driver: driver.find_element_by_css_selector(
|
||||
".loading-logs"), 10)
|
||||
lambda driver: driver.find_element(
|
||||
By.CSS_SELECTOR, ".loading-logs"), 10)
|
||||
self.assertEqual(status, expected_backup_success_msg)
|
||||
|
||||
# Check for XSS in Restore details
|
||||
@ -209,15 +209,16 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
|
||||
try:
|
||||
take_bckup.click()
|
||||
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)):
|
||||
click = False
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def initiate_restore(self):
|
||||
tools_menu = self.driver.find_element_by_link_text(
|
||||
NavMenuLocators.tools_menu_link_text)
|
||||
tools_menu = self.driver.find_element(
|
||||
By.LINK_TEXT, NavMenuLocators.tools_menu_link_text)
|
||||
tools_menu.click()
|
||||
|
||||
restore_obj = self.page.find_by_css_selector(
|
||||
@ -239,7 +240,8 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
|
||||
restore_btn.click()
|
||||
|
||||
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))
|
||||
|
||||
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']
|
||||
if default_binary_path is not None:
|
||||
def get_server_version_string():
|
||||
server_version = {130000: '13', 120000: '12', 110000: '11',
|
||||
100000: '10', 90600: '9.6'}
|
||||
server_version = {140000: '14', 130000: '13', 120000: '12',
|
||||
110000: '11', 100000: '10', 90600: '9.6'}
|
||||
for k, v in server_version.items():
|
||||
if k <= self.server_information['server_version']:
|
||||
return v
|
||||
@ -317,5 +319,5 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
|
||||
self.page.click_modal('Save')
|
||||
|
||||
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")
|
||||
)
|
||||
|
@ -81,8 +81,8 @@ class PGUtilitiesMaintenanceFeatureTest(BaseFeatureTest):
|
||||
self._open_maintenance_dialogue()
|
||||
self.page.click_modal('OK')
|
||||
self.page.wait_for_element_to_disappear(
|
||||
lambda driver: driver.find_element_by_xpath(
|
||||
NavMenuLocators.maintenance_operation))
|
||||
lambda driver: driver.find_element(
|
||||
By.XPATH, NavMenuLocators.maintenance_operation))
|
||||
|
||||
# Wait for the backup status alertfier
|
||||
self.wait.until(EC.visibility_of_element_located(
|
||||
@ -129,8 +129,8 @@ class PGUtilitiesMaintenanceFeatureTest(BaseFeatureTest):
|
||||
(By.XPATH,
|
||||
NavMenuLocators.process_watcher_alertfier))
|
||||
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.":
|
||||
self.assertEqual(status, "Successfully completed.")
|
||||
|
@ -468,8 +468,9 @@ SELECT relname FROM pg_catalog.pg_class
|
||||
canvas = self.wait.until(EC.presence_of_element_located(
|
||||
(By.CSS_SELECTOR, QueryToolLocators.query_output_canvas_css)))
|
||||
|
||||
el = canvas.find_elements_by_xpath(
|
||||
QueryToolLocators.output_column_data_xpath.format(table_name))
|
||||
el = canvas.find_elements(
|
||||
By.XPATH, QueryToolLocators.output_column_data_xpath.format(
|
||||
table_name))
|
||||
|
||||
assert len(el) != 0, "Table '{}' is not created with auto " \
|
||||
"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(
|
||||
(By.CSS_SELECTOR, QueryToolLocators.query_output_canvas_css)))
|
||||
|
||||
el = canvas.find_elements_by_xpath(
|
||||
QueryToolLocators.output_column_data_xpath.format(table_name))
|
||||
el = canvas.find_elements(
|
||||
By.XPATH, QueryToolLocators.output_column_data_xpath.format(
|
||||
table_name))
|
||||
|
||||
assert len(el) == 0, "Table '{}' created even after ROLLBACK due to " \
|
||||
"sql error.".format(table_name)
|
||||
|
@ -56,8 +56,8 @@ class CopySQLFeatureTest(BaseFeatureTest):
|
||||
% self.test_table_name, 10), "No data displayed in SQL tab")
|
||||
|
||||
# Fetch the inner html & check for escaped characters
|
||||
source_code = self.driver.find_elements_by_xpath(
|
||||
QueryToolLocators.code_mirror_data_xpath)
|
||||
source_code = self.driver.find_elements(
|
||||
By.XPATH, QueryToolLocators.code_mirror_data_xpath)
|
||||
|
||||
sql_query = ''
|
||||
for data in source_code:
|
||||
@ -74,10 +74,10 @@ class CopySQLFeatureTest(BaseFeatureTest):
|
||||
|
||||
self.driver.switch_to.default_content()
|
||||
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(
|
||||
QueryToolLocators.code_mirror_data_xpath)
|
||||
code_mirror = self.driver.find_elements(
|
||||
By.XPATH, QueryToolLocators.code_mirror_data_xpath)
|
||||
query_tool_result = ''
|
||||
for data in code_mirror:
|
||||
query_tool_result += data.text
|
||||
|
@ -285,7 +285,7 @@ class CheckForXssFeatureTest(BaseFeatureTest):
|
||||
|
||||
self.page.find_by_css_selector(".slick-header-column")
|
||||
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.
|
||||
# currently 4th col
|
||||
@ -315,9 +315,9 @@ class CheckForXssFeatureTest(BaseFeatureTest):
|
||||
# Re-try logic
|
||||
try:
|
||||
ActionChains(self.driver).move_to_element(
|
||||
self.driver.find_element_by_css_selector(
|
||||
'div.pgadmin-explain-container > svg > g > g > image'
|
||||
)
|
||||
self.driver.find_element(
|
||||
By.CSS_SELECTOR,
|
||||
'div.pgadmin-explain-container > svg > g > g > image')
|
||||
).click().perform()
|
||||
break
|
||||
except Exception:
|
||||
@ -331,7 +331,8 @@ class CheckForXssFeatureTest(BaseFeatureTest):
|
||||
)
|
||||
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')
|
||||
|
||||
self._check_escaped_characters(
|
||||
|
@ -134,7 +134,7 @@ class CheckDebuggerForXssFeatureTest(BaseFeatureTest):
|
||||
self._close_debugger()
|
||||
|
||||
def _close_debugger(self):
|
||||
self.page.driver.switch_to_default_content()
|
||||
self.page.driver.switch_to.default_content()
|
||||
self.page.click_element(
|
||||
self.page.find_by_xpath(
|
||||
"//*[@id='dockerContainer']/div/div[3]/div/div[2]/div[1]")
|
||||
|
@ -193,7 +193,7 @@ class PgadminPage:
|
||||
" 'Remove Panel')]").click()
|
||||
if prompt:
|
||||
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)
|
||||
self.click_element(self.find_by_xpath(
|
||||
'//button[contains(@class, "ajs-button") and '
|
||||
@ -241,8 +241,8 @@ class PgadminPage:
|
||||
def check_execute_option(self, option):
|
||||
""""This function will check auto commit or auto roll back based on
|
||||
user input. If button is already checked, no action will be taken"""
|
||||
query_options = self.driver.find_element_by_css_selector(
|
||||
QueryToolLocators.btn_query_dropdown)
|
||||
query_options = self.driver.find_element(
|
||||
By.CSS_SELECTOR, QueryToolLocators.btn_query_dropdown)
|
||||
expanded = query_options.get_attribute("aria-expanded")
|
||||
if expanded == "false":
|
||||
query_options.click()
|
||||
@ -250,8 +250,8 @@ class PgadminPage:
|
||||
def update_execute_option_setting(
|
||||
css_selector_of_option_status, css_selector_of_option,):
|
||||
retry = 3
|
||||
check_status = self.driver.find_element_by_css_selector(
|
||||
css_selector_of_option_status)
|
||||
check_status = self.driver.find_element(
|
||||
By.CSS_SELECTOR, css_selector_of_option_status)
|
||||
if 'visibility-hidden' in check_status.get_attribute('class'):
|
||||
while retry > 0:
|
||||
self.find_by_css_selector(css_selector_of_option).click()
|
||||
|
@ -1439,11 +1439,7 @@ def get_parallel_sequential_module_list(module_list):
|
||||
"""
|
||||
# list of files consisting tests that needs to be
|
||||
# executed sequentially
|
||||
sequential_tests_file = [
|
||||
'pgadmin.feature_tests.pg_utilities_backup_restore_test',
|
||||
'pgadmin.feature_tests.pg_utilities_maintenance_test',
|
||||
'pgadmin.feature_tests.keyboard_shortcut_test'
|
||||
]
|
||||
sequential_tests_file = []
|
||||
|
||||
# list of tests can be executed in parallel
|
||||
parallel_tests = list(module_list)
|
||||
|
@ -25,5 +25,5 @@ python-mimeparse==1.6.0
|
||||
testscenarios==0.5.0
|
||||
testtools==2.3.0
|
||||
traceback2==1.4.0
|
||||
selenium==4.0.0
|
||||
selenium==4.0.0a6
|
||||
coverage==5.0.1
|
||||
|
Loading…
Reference in New Issue
Block a user