Hi Hackers,

Please find the attached for some feature test cases fixes.


   1. pg_datatype_validation_test.py
   2. pg_utilities_backup_restore_test.py
   3. test_copy_sql_to_query_tool.py
   4. browser_tool_bar_test.py
   5. keyboard_shortcut_test.py


-- 
Thanks & Regards,
Pradip Parkale
Software Engineer | EnterpriseDB Corporation
diff --git a/web/pgadmin/feature_tests/browser_tool_bar_test.py b/web/pgadmin/feature_tests/browser_tool_bar_test.py
index 0ce749b65..a068e0160 100644
--- a/web/pgadmin/feature_tests/browser_tool_bar_test.py
+++ b/web/pgadmin/feature_tests/browser_tool_bar_test.py
@@ -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)
diff --git a/web/pgadmin/feature_tests/keyboard_shortcut_test.py b/web/pgadmin/feature_tests/keyboard_shortcut_test.py
index 397fd4cd7..38834fda2 100644
--- a/web/pgadmin/feature_tests/keyboard_shortcut_test.py
+++ b/web/pgadmin/feature_tests/keyboard_shortcut_test.py
@@ -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)
 
-        # save and close the preference dialog.
-        self.page.click_modal('Save')
+        maximize_button = self.page.find_by_xpath(
+            NavMenuLocators.maximize_pref_dialogue_css)
+        maximize_button.click()
 
-        self.page.wait_for_element_to_disappear(
-            lambda driver: driver.find_element(By.CSS_SELECTOR, ".ajs-modal")
-        )
+        # save and close the preference dialog.
+        self.page.click_modal('Save', True)
diff --git a/web/pgadmin/feature_tests/pg_datatype_validation_test.py b/web/pgadmin/feature_tests/pg_datatype_validation_test.py
index ce1d498a4..9b91cdf21 100644
--- a/web/pgadmin/feature_tests/pg_datatype_validation_test.py
+++ b/web/pgadmin/feature_tests/pg_datatype_validation_test.py
@@ -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)
 
-        # save and close the preference dialog.
-        self.page.click_modal('Save')
+        switch_box_element.click()
 
-        self.page.wait_for_element_to_disappear(
-            lambda driver: driver.find_element(By.CSS_SELECTOR, ".ajs-modal")
-        )
+        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', 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])
                  )
             ))
 
diff --git a/web/pgadmin/feature_tests/pg_utilities_backup_restore_test.py b/web/pgadmin/feature_tests/pg_utilities_backup_restore_test.py
index 5810f68df..474645940 100644
--- a/web/pgadmin/feature_tests/pg_utilities_backup_restore_test.py
+++ b/web/pgadmin/feature_tests/pg_utilities_backup_restore_test.py
@@ -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")
diff --git a/web/pgadmin/feature_tests/test_copy_sql_to_query_tool.py b/web/pgadmin/feature_tests/test_copy_sql_to_query_tool.py
index 98a1b5b84..83bf0e93f 100644
--- a/web/pgadmin/feature_tests/test_copy_sql_to_query_tool.py
+++ b/web/pgadmin/feature_tests/test_copy_sql_to_query_tool.py
@@ -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)
diff --git a/web/regression/feature_utils/locators.py b/web/regression/feature_utils/locators.py
index b5f7dba7c..db0c0ae4f 100644
--- a/web/regression/feature_utils/locators.py
+++ b/web/regression/feature_utils/locators.py
@@ -24,7 +24,8 @@ class BrowserToolBarLocators():
     filter_data_button_css = \
         ".wcFrameButton[title='Filtered Rows']:not(.disabled)"
 
-    filter_alertify_box_css = ".wcPanelTab.wcPanelTabActive.wcNotMoveable"
+    filter_alertify_box_css = "//*[@id='0']/div[contains(text()," \
+                              "'Data Filter')]"
 
 
 class NavMenuLocators:
@@ -51,34 +52,30 @@ class NavMenuLocators:
     show_system_objects_pref_label_xpath = \
         "//label[contains(text(), 'Show system objects?')]"
 
-    maximize_pref_dialogue_css = ".ajs-dialog.pg-el-container .ajs-maximize"
+    maximize_pref_dialogue_css = "//div[text()='Preferences']" \
+                                 "//following::div//span[1]"
 
     specified_pref_node_exp_status = \
-        "//div[div[span[span[(@class='aciTreeText')and " \
-        "(text()='{0} ' or text()='{0}')]]]]"
+        "//*[@id='treeContainer']//div//span[text()='{0}']"
 
     specified_preference_tree_node = \
-        "//div//span[(@class='aciTreeText')and " \
-        "(text()='{0} ' or text()='{0}')]"
+        "//*[@id='treeContainer']//div//span[text()='{0}']" \
 
     specified_sub_node_of_pref_tree_node = \
-        "//span[text()='{0}']//following::span[text()='{1}']"
-
+        "//*[@id='treeContainer']//div//span[text()='{1}']"
     insert_bracket_pair_switch_btn = \
-        "//div[span[normalize-space(text())='Insert bracket pairs?']]" \
-        "//div[contains(@class,'toggle btn')]"
+        "//label[text()='Insert bracket pairs?']//following::div[1]//span"
 
     copy_sql_to_query_tool_switch_btn = \
-        "//div[span[normalize-space(text())=" \
-        "'Copy SQL from main window to query tool?']]" \
-        "//div[contains(@class,'toggle btn')]"
+        "//label[text()='Copy SQL from main window to query tool?']" \
+        "//following::div[1]//span"
 
     backup_filename_txt_box_name = "file"
 
     restore_file_name_txt_box_name = "file"
 
     backup_btn_xpath = \
-        "//button[ contains(.,'Backup')]"
+        "//button/span[text()='Backup']"
 
     bcg_process_status_alertifier_css = \
         ".ajs-message.ajs-bg-bgprocess.ajs-visible"
diff --git a/web/regression/feature_utils/pgadmin_page.py b/web/regression/feature_utils/pgadmin_page.py
index d9d53c446..c1d1b3064 100644
--- a/web/regression/feature_utils/pgadmin_page.py
+++ b/web/regression/feature_utils/pgadmin_page.py
@@ -87,9 +87,8 @@ class PgadminPage:
 
         # In case of react dialog we use different xpath
         if react_dialog:
-            modal_button = self.find_by_css_selector(
-                ".react-draggable button[data-label='{0}']"
-                .format(button_text))
+            modal_button = self.find_by_xpath(
+                "//span[text()='{}']".format(button_text))
         else:
             modal_button = self.find_by_xpath(
                 "//div[contains(@class, 'alertify') and "

Reply via email to