Fixed feature test case failed as a result of converting preferences and other dialogs to React.

This commit is contained in:
Pradip Parkale
2022-05-17 19:06:24 +05:30
committed by Akshay Joshi
parent 2d8aff6ca0
commit 6465dc951c
7 changed files with 106 additions and 86 deletions

View File

@@ -90,7 +90,7 @@ class BrowserToolBarFeatureTest(BaseFeatureTest):
self.assertTrue(self.page.retry_click(
(By.CSS_SELECTOR,
BrowserToolBarLocators.filter_data_button_css),
(By.CSS_SELECTOR, BrowserToolBarLocators.filter_alertify_box_css)),
(By.XPATH, BrowserToolBarLocators.filter_alertify_box_css)),
'Filter dialogue did not open on clicking filter button.')
self.page.click_modal('Close', True)
self.page.close_query_tool(prompt=False)

View File

@@ -93,12 +93,8 @@ class KeyboardShortcutFeatureTest(BaseFeatureTest):
NavMenuLocators.preference_menu_item_css)
pref_menu_item.click()
browser_node = self.page.find_by_xpath(
self.page.find_by_xpath(
NavMenuLocators.specified_preference_tree_node.format('Browser'))
if self.page.find_by_xpath(
NavMenuLocators.specified_pref_node_exp_status.
format('Browser')).get_attribute('aria-expanded') == 'false':
ActionChains(self.driver).double_click(browser_node).perform()
display_node = self.page.find_by_xpath(
NavMenuLocators.specified_sub_node_of_pref_tree_node.format(
@@ -116,7 +112,7 @@ class KeyboardShortcutFeatureTest(BaseFeatureTest):
else:
attempt -= 1
maximize_button = self.page.find_by_css_selector(
maximize_button = self.page.find_by_xpath(
NavMenuLocators.maximize_pref_dialogue_css)
maximize_button.click()
@@ -128,18 +124,17 @@ class KeyboardShortcutFeatureTest(BaseFeatureTest):
for s in self.new_shortcuts:
key = self.new_shortcuts[s]['shortcut'][2]
locator = self.new_shortcuts[s]['locator']
file_menu = self.page.find_by_xpath(
"//div[contains(@class,'pgadmin-control-group') "
"and contains(.,'" + locator + "')]"
)
file_menu = \
self.page.find_by_xpath("//div[label[text()='{}']]"
"/following-sibling::div//div/"
"input".format(locator))
field = file_menu.find_element(By.NAME, 'key')
field.click()
field.send_keys(key)
file_menu.click()
file_menu.send_keys(key)
maximize_button = self.page.find_by_xpath(
NavMenuLocators.maximize_pref_dialogue_css)
maximize_button.click()
# save and close the preference dialog.
self.page.click_modal('Save')
self.page.wait_for_element_to_disappear(
lambda driver: driver.find_element(By.CSS_SELECTOR, ".ajs-modal")
)
self.page.click_modal('Save', True)

View File

@@ -111,7 +111,7 @@ class PGDataypeFeatureTest(BaseFeatureTest):
(By.XPATH, NavMenuLocators.show_system_objects_pref_label_xpath))
)
maximize_button = self.page.find_by_css_selector(
maximize_button = self.page.find_by_xpath(
NavMenuLocators.maximize_pref_dialogue_css)
maximize_button.click()
@@ -125,30 +125,32 @@ class PGDataypeFeatureTest(BaseFeatureTest):
get_attribute('aria-expanded') == 'false':
ActionChains(self.driver).double_click(sql_editor).perform()
option_node = self.page.find_by_xpath(
NavMenuLocators.specified_sub_node_of_pref_tree_node.format(
specified_preference_tree_node_name, 'Editor'))
option_node = \
self.page.find_by_xpath("//*[@id='treeContainer']"
"//div//span[text()='Editor']")
option_node.click()
self.page.set_switch_box_status(
NavMenuLocators.insert_bracket_pair_switch_btn, 'No')
switch_box_element = self.page.find_by_xpath(
NavMenuLocators.insert_bracket_pair_switch_btn)
switch_box_element.click()
maximize_button = self.page.find_by_xpath(
NavMenuLocators.maximize_pref_dialogue_css)
maximize_button.click()
time.sleep(0.5)
# save and close the preference dialog.
self.page.click_modal('Save')
self.page.wait_for_element_to_disappear(
lambda driver: driver.find_element(By.CSS_SELECTOR, ".ajs-modal")
)
time.sleep(0.5)
self.page.click_modal('Save', react_dialog=True)
def _create_enum_type(self):
query = """CREATE TYPE public.rainbow AS ENUM ('red', 'orange',
'yellow','green','blue','purple');
"""
self.page.fill_codemirror_area_with(query)
execute_query = self.page.find_by_css_selector(
QueryToolLocators.btn_execute_query_css)
execute_query.click()
time.sleep(0.5)
self.page.find_by_css_selector(
QueryToolLocators.btn_execute_query_css).click()
self.page.clear_query_tool()
def runTest(self):
@@ -160,7 +162,7 @@ class PGDataypeFeatureTest(BaseFeatureTest):
# Check data types
self._check_datatype()
self.page.close_query_tool()
self.page.close_query_tool(False)
def after(self):
self.page.remove_server(self.server)
@@ -184,13 +186,13 @@ class PGDataypeFeatureTest(BaseFeatureTest):
# wait for the visibility of the grid to appear
wait.until(EC.visibility_of_element_located(
(By.XPATH,
"//*[contains(@class,'column-type')]"
"//*[contains(@class,'makeStyles-columnName')]"
)
))
wait.until(EC.visibility_of_element_located(
(By.XPATH,
"//*[contains(@class,'column-type') and "
"contains(.,'{}')]".format(batch['datatype'][0])
"//*[contains(@class,'makeStyles-columnName') "
"and //span[text()='{}']]".format(batch['datatype'][0])
)
))

View File

@@ -216,8 +216,8 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
take_bckup.click()
if self.page.wait_for_element_to_disappear(
lambda driver: driver.find_element(
By.NAME,
NavMenuLocators.backup_filename_txt_box_name)):
By.XPATH,
"//*[@id='0']/div[contains(text(),'Backup')]")):
click = False
except Exception:
retry -= 1
@@ -282,7 +282,7 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
(By.XPATH, NavMenuLocators.show_system_objects_pref_label_xpath))
)
maximize_button = self.page.find_by_css_selector(
maximize_button = self.page.find_by_xpath(
NavMenuLocators.maximize_pref_dialogue_css)
maximize_button.click()
@@ -309,27 +309,44 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
return None
server_version = get_server_version_string()
server_types = default_binary_path.keys()
path_already_set = True
for serv in server_types:
if serv == 'pg' and server_version is not None:
path_input = self.page.find_by_xpath(
"//td[span[text()='PostgreSQL {0}']]"
"/following-sibling::td//input".format(server_version))
self.page.clear_edit_box(path_input)
path_input.click()
path_input.send_keys(default_binary_path['pg'])
path_input = \
self.page.find_by_xpath(
"//div[span[text()='PostgreSQL {}']]"
"/following-sibling::div//div/input".format(
server_version))
exiting_path = path_input.get_property("value")
if exiting_path != default_binary_path['pg']:
path_already_set = False
self.page.clear_edit_box(path_input)
path_input.click()
path_input.send_keys(default_binary_path['pg'])
elif serv == 'ppas' and server_version is not None:
path_input = self.page.find_by_xpath(
"//td[span[text()='EDB Advanced Server {0}']]"
"/following-sibling::td//input".format(server_version))
self.page.clear_edit_box(path_input)
path_input.click()
path_input.send_keys(default_binary_path['ppas'])
if exiting_path != default_binary_path['pg']:
path_already_set = False
path_input = self.page.find_by_xpath(
"//div[span[text()='EDB Advanced Server {}']]"
"/following-sibling::div//div/input".format(
server_version))
self.page.clear_edit_box(path_input)
path_input.click()
path_input.send_keys(default_binary_path['ppas'])
else:
print('Binary path Key is Incorrect or '
'server version is None.')
maximize_button = self.page.find_by_xpath(
NavMenuLocators.maximize_pref_dialogue_css)
maximize_button.click()
# save and close the preference dialog.
self.page.click_modal('Save')
if path_already_set:
self.page.click_modal('Cancel', True)
else:
self.page.click_modal('Save', True)
self.page.wait_for_element_to_disappear(
lambda driver: driver.find_element(By.CSS_SELECTOR, ".ajs-modal")

View File

@@ -9,7 +9,6 @@
import random
import time
from regression.feature_utils.base_feature_test import BaseFeatureTest
from regression.python_test_utils import test_utils
from regression.feature_utils.tree_area_locators import TreeAreaLocators
@@ -109,28 +108,28 @@ class CopySQLFeatureTest(BaseFeatureTest):
wait = WebDriverWait(self.page.driver, 10)
browser_node = self.page.find_by_xpath(
NavMenuLocators.specified_preference_tree_node.format('Browser'))
if self.page.find_by_xpath(
NavMenuLocators.specified_pref_node_exp_status.
format('Browser')).get_attribute('aria-expanded') == 'false':
ActionChains(self.driver).double_click(browser_node).perform()
self.page.retry_click(
(By.XPATH, NavMenuLocators.specified_sub_node_of_pref_tree_node.
(By.XPATH,
NavMenuLocators.specified_sub_node_of_pref_tree_node.
format('Browser', 'Display')),
(By.XPATH, NavMenuLocators.show_system_objects_pref_label_xpath))
(By.XPATH,
NavMenuLocators.show_system_objects_pref_label_xpath))
# Wait till the preference dialogue box is displayed by checking the
# visibility of Show System Object label
wait.until(EC.presence_of_element_located(
(By.XPATH, NavMenuLocators.show_system_objects_pref_label_xpath))
)
maximize_button = self.page.find_by_xpath(
NavMenuLocators.maximize_pref_dialogue_css)
maximize_button.click()
specified_preference_tree_node_name = 'Query Tool'
sql_editor = self.page.find_by_xpath(
NavMenuLocators.specified_preference_tree_node.format(
specified_preference_tree_node_name))
print(sql_editor)
sql_editor.click()
if self.page.find_by_xpath(
NavMenuLocators.specified_pref_node_exp_status.
format(specified_preference_tree_node_name)).get_attribute(
@@ -138,12 +137,23 @@ class CopySQLFeatureTest(BaseFeatureTest):
ActionChains(self.driver).double_click(sql_editor).perform()
option_node = self.page.find_by_xpath(
NavMenuLocators.specified_sub_node_of_pref_tree_node.format(
specified_preference_tree_node_name, 'Options'))
"//*[@id='treeContainer']//div//span[text()="
"'Results grid']//preceding::span[text()='Options']")
print(option_node)
# self.page.check_if_element_exists_with_scroll(option_node)
self.page.driver.execute_script("arguments[0].scrollIntoView(false)",
option_node)
option_node.click()
self.page.set_switch_box_status(
NavMenuLocators.copy_sql_to_query_tool_switch_btn, 'Yes')
switch_box_element = \
self.page.find_by_xpath(NavMenuLocators.
copy_sql_to_query_tool_switch_btn)
switch_box_element.click()
maximize_button = self.page.find_by_xpath(
NavMenuLocators.maximize_pref_dialogue_css)
maximize_button.click()
# save and close the preference dialog.
self.page.click_modal('Save')
self.page.click_modal('Save', react_dialog=True)