diff --git a/web/pgadmin/feature_tests/query_tool_journey_test.py b/web/pgadmin/feature_tests/query_tool_journey_test.py
index 88d30a1c1..216de6926 100644
--- a/web/pgadmin/feature_tests/query_tool_journey_test.py
+++ b/web/pgadmin/feature_tests/query_tool_journey_test.py
@@ -429,7 +429,12 @@ class QueryToolJourneyTest(BaseFeatureTest):
         ActionChains(self.driver).double_click(cell_el).perform()
         ActionChains(self.driver).send_keys(new_value). \
             send_keys(Keys.ENTER).perform()
+
         # Check if the value was updated
+        # Finding element again to avoid stale element reference exception
+        cell_el = self.page.find_by_xpath(
+            "//div[contains(@style, 'top:0px')]//div[contains(@class, "
+            "'l{0} r{1}')]".format(cell_index, cell_index))
         return int(cell_el.text) == new_value
 
     def _check_can_add_row(self):
@@ -438,6 +443,8 @@ class QueryToolJourneyTest(BaseFeatureTest):
 
     def after(self):
         self.page.close_query_tool()
-        self.page.remove_server(self.server)
         test_utils.delete_table(
             self.server, self.test_db, self.test_table_name)
+        test_utils.delete_table(
+            self.server, self.test_db, self.test_editable_table_name)
+        self.page.remove_server(self.server)
diff --git a/web/pgadmin/feature_tests/query_tool_tests.py b/web/pgadmin/feature_tests/query_tool_tests.py
index a0f350320..de6c479f5 100644
--- a/web/pgadmin/feature_tests/query_tool_tests.py
+++ b/web/pgadmin/feature_tests/query_tool_tests.py
@@ -135,10 +135,10 @@ class QueryToolFeatureTest(BaseFeatureTest):
         query_op.click()
 
         # disable auto rollback only if they are enabled
-        self.uncheck_execute_option('auto_rollback')
+        self.page.uncheck_execute_option('auto_rollback')
 
         # enable autocommit only if it's disabled
-        self.check_execute_option('auto_commit')
+        self.page.check_execute_option('auto_commit')
 
         # close menu
         query_op.click()
@@ -343,7 +343,7 @@ CREATE TABLE public.{}();""".format(table_name)
         query_op = self.page.find_by_css_selector(
             QueryToolLocators.btn_query_dropdown)
         query_op.click()
-        self.uncheck_execute_option('auto_commit')
+        self.page.uncheck_execute_option('auto_commit')
         # close option
         query_op.click()
 
@@ -413,7 +413,7 @@ END;"""
         query_op.click()
 
         # Enable auto_commit if it is disabled
-        self.check_execute_option('auto_commit')
+        self.page.check_execute_option('auto_commit')
 
         query_op.click()
 
@@ -492,8 +492,8 @@ END;"""
         query_op.click()
 
         # uncheck auto commit and check auto-rollback
-        self.uncheck_execute_option('auto_commit')
-        self.check_execute_option('auto_rollback')
+        self.page.uncheck_execute_option('auto_commit')
+        self.page.check_execute_option('auto_rollback')
 
         query_op.click()
 
@@ -588,8 +588,8 @@ SELECT 1, pg_sleep(300)"""
         query_op.click()
 
         # enable auto-commit and disable auto-rollback
-        self.check_execute_option('auto_commit')
-        self.uncheck_execute_option('auto_rollback')
+        self.page.check_execute_option('auto_commit')
+        self.page.uncheck_execute_option('auto_rollback')
         # close drop down
         query_op.click()
         # Execute query
@@ -729,38 +729,6 @@ SELECT 1, pg_sleep(300)"""
 
         self.page.clear_query_tool()
 
-    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"""
-        if option == 'auto_commit':
-            check_status = self.driver.find_element_by_css_selector(
-                QueryToolLocators.btn_auto_commit_check_status)
-            if 'visibility-hidden' in check_status.get_attribute('class'):
-                self.page.find_by_css_selector(QueryToolLocators.
-                                               btn_auto_commit).click()
-        if option == 'auto_rollback':
-            check_status = self.driver.find_element_by_css_selector(
-                QueryToolLocators.btn_auto_rollback_check_status)
-            if 'visibility-hidden' in check_status.get_attribute('class'):
-                self.page.find_by_css_selector(QueryToolLocators.
-                                               btn_auto_rollback).click()
-
-    def uncheck_execute_option(self, option):
-        """"This function will uncheck auto commit or auto roll back based on
-        user input. If button is already unchecked, no action will be taken"""
-        if option == 'auto_commit':
-            check_status = self.driver.find_element_by_css_selector(
-                QueryToolLocators.btn_auto_commit_check_status)
-            if 'visibility-hidden' not in check_status.get_attribute('class'):
-                self.page.find_by_css_selector(QueryToolLocators.
-                                               btn_auto_commit).click()
-        if option == 'auto_rollback':
-            check_status = self.driver.find_element_by_css_selector(
-                QueryToolLocators.btn_auto_rollback_check_status)
-            if 'visibility-hidden' not in check_status.get_attribute('class'):
-                self.page.find_by_css_selector(QueryToolLocators.
-                                               btn_auto_rollback).click()
-
 
 class WaitForAnyElementWithText(object):
     def __init__(self, locator, text):
diff --git a/web/pgadmin/feature_tests/view_data_dml_queries.py b/web/pgadmin/feature_tests/view_data_dml_queries.py
index 14591cdae..381be22dc 100644
--- a/web/pgadmin/feature_tests/view_data_dml_queries.py
+++ b/web/pgadmin/feature_tests/view_data_dml_queries.py
@@ -349,8 +349,6 @@ CREATE TABLE public.nonintpkey
 
         self.page.wait_for_query_tool_loading_indicator_to_disappear()
 
-        result_row = self.page.find_by_xpath(xpath)
-
         # Verify the List of actual values with the expected list
         actual_list = list(config_check_data.keys())
         for value in range(0, len(actual_list)):
@@ -360,14 +358,15 @@ CREATE TABLE public.nonintpkey
         for idx in actual_list:
             while retry > 0:
                 try:
+                    result_row = self.page.find_by_xpath(xpath)
                     element = \
                         result_row.find_element_by_class_name("r" + str(idx))
+                    self.page.driver.execute_script(
+                        "arguments[0].scrollIntoView(false)", element)
                     break
                 except Exception:
                     print("stale reference exception at id:", idx)
                     retry -= 1
-            self.page.driver.execute_script(
-                "arguments[0].scrollIntoView(false)", element)
             time.sleep(0.4)
             self.assertEquals(element.text, config_check_data[str(idx)][1])
 
diff --git a/web/pgadmin/feature_tests/xss_checks_roles_control_test.py b/web/pgadmin/feature_tests/xss_checks_roles_control_test.py
index ab4c4241e..3a6e09adb 100644
--- a/web/pgadmin/feature_tests/xss_checks_roles_control_test.py
+++ b/web/pgadmin/feature_tests/xss_checks_roles_control_test.py
@@ -13,6 +13,7 @@ import random
 from regression.python_test_utils import test_utils
 from regression.feature_utils.base_feature_test import BaseFeatureTest
 from regression.feature_utils.locators import NavMenuLocators
+from regression.feature_utils.tree_area_locators import TreeAreaLocators
 from selenium.webdriver.common.by import By
 from selenium.webdriver.support import expected_conditions as EC
 from selenium.webdriver.support.ui import WebDriverWait
@@ -61,7 +62,8 @@ class CheckRoleMembershipControlFeatureTest(BaseFeatureTest):
         self.page.expand_server_node(
             self.server['name'], self.server['db_password'])
         self.page.toggle_open_tree_item('Login/Group Roles')
-        self.page.select_tree_item(role)
+        self.page.click_a_tree_node(
+            role, TreeAreaLocators.sub_nodes_of_login_group_node)
 
     def _check_role_membership_control(self):
         self.page.driver.find_element_by_link_text(
diff --git a/web/pgadmin/tools/datagrid/templates/datagrid/index.html b/web/pgadmin/tools/datagrid/templates/datagrid/index.html
index 9c05e641b..aaf5f91b5 100644
--- a/web/pgadmin/tools/datagrid/templates/datagrid/index.html
+++ b/web/pgadmin/tools/datagrid/templates/datagrid/index.html
@@ -240,7 +240,7 @@
                 </button>
                 <button id="btn-flash" data-test-selector="execute-refresh-button" type="button" class="btn btn-sm btn-secondary" style="width: 32px;"
                         title=""
-                        tabindex="0" disabled>
+                        tabindex="0" data-click-counter="0" disabled>
                     <i class="fa fa-bolt sql-icon-lg" aria-hidden="true"></i>
                 </button>
                 <button id="btn-query-dropdown" type="button" class="btn btn-sm btn-secondary dropdown-toggle dropdown-toggle-split"
diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
index 70d4bd348..9d9ab5c84 100644
--- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
@@ -1653,6 +1653,10 @@ define('tools.querytool', [
 
     // Callback function for the flash button click.
     on_flash: function() {
+      let data_click_counter = $('#btn-flash').attr('data-click-counter');
+      data_click_counter = (parseInt(data_click_counter) + 1)%10;
+      $('#btn-flash').attr('data-click-counter', data_click_counter);
+
       this.handler.history_query_source = QuerySources.EXECUTE;
 
       queryToolActions.executeQuery(this.handler);
diff --git a/web/regression/feature_utils/pgadmin_page.py b/web/regression/feature_utils/pgadmin_page.py
index 61aa4cf5a..a754a3e25 100644
--- a/web/regression/feature_utils/pgadmin_page.py
+++ b/web/regression/feature_utils/pgadmin_page.py
@@ -180,9 +180,15 @@ class PgadminPage:
         retry = 5
         execute_button = self.find_by_css_selector(
             QueryToolLocators.btn_execute_query_css)
+        first_click = execute_button.get_attribute('data-click-counter')
         while retry > 0:
             execute_button.click()
-            if self.wait_for_query_tool_loading_indicator_to_appear():
+            execute_button = self.find_by_css_selector(
+                QueryToolLocators.btn_execute_query_css)
+            second_click = execute_button.get_attribute(
+                'data-click-counter')
+            if first_click != second_click:
+                self.wait_for_query_tool_loading_indicator_to_appear()
                 break
             else:
                 retry -= 1
@@ -191,34 +197,65 @@ 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"""
+        retry = 3
         if option == 'auto_commit':
             check_status = self.driver.find_element_by_css_selector(
                 QueryToolLocators.btn_auto_commit_check_status)
             if 'visibility-hidden' in check_status.get_attribute('class'):
-                self.find_by_css_selector(
-                    QueryToolLocators.btn_auto_commit).click()
+                while retry > 0:
+                    self.find_by_css_selector(
+                        QueryToolLocators.btn_auto_commit).click()
+                    time.sleep(0.2)
+                    if 'visibility-hidden' not in \
+                            check_status.get_attribute('class'):
+                        break
+                    else:
+                        retry -= 1
+
         if option == 'auto_rollback':
             check_status = self.driver.find_element_by_css_selector(
                 QueryToolLocators.btn_auto_rollback_check_status)
             if 'visibility-hidden' in check_status.get_attribute('class'):
-                self.find_by_css_selector(
-                    QueryToolLocators.btn_auto_rollback).click()
+                while retry > 0:
+                    self.find_by_css_selector(
+                        QueryToolLocators.btn_auto_rollback).click()
+                    time.sleep(0.2)
+                    if 'visibility-hidden' not in \
+                            check_status.get_attribute('class'):
+                        break
+                    else:
+                        retry -= 1
 
     def uncheck_execute_option(self, option):
         """"This function will uncheck auto commit or auto roll back based on
         user input. If button is already unchecked, no action will be taken"""
+        retry = 3
         if option == 'auto_commit':
             check_status = self.driver.find_element_by_css_selector(
                 QueryToolLocators.btn_auto_commit_check_status)
             if 'visibility-hidden' not in check_status.get_attribute('class'):
-                self.find_by_css_selector(
-                    QueryToolLocators.btn_auto_commit).click()
+                while retry > 0:
+                    self.find_by_css_selector(
+                        QueryToolLocators.btn_auto_commit).click()
+                    time.sleep(0.2)
+                    if 'visibility-hidden' in \
+                            check_status.get_attribute('class'):
+                        break
+                    else:
+                        retry -= 1
         if option == 'auto_rollback':
             check_status = self.driver.find_element_by_css_selector(
                 QueryToolLocators.btn_auto_rollback_check_status)
             if 'visibility-hidden' not in check_status.get_attribute('class'):
-                self.find_by_css_selector(
-                    QueryToolLocators.btn_auto_rollback).click()
+                while retry > 0:
+                    self.find_by_css_selector(
+                        QueryToolLocators.btn_auto_rollback).click()
+                    time.sleep(0.2)
+                    if 'visibility-hidden' in \
+                            check_status.get_attribute('class'):
+                        break
+                    else:
+                        retry -= 1
 
     def close_data_grid(self):
         self.driver.switch_to_default_content()
@@ -273,9 +310,7 @@ class PgadminPage:
                 self.wait_for_elements_to_appear(
                     self.driver, list_of_element[index_of_element])
                 time.sleep(1)
-                self.driver.execute_script(
-                    "arguments[0].click()",
-                    list_of_element[index_of_element])
+                list_of_element[index_of_element].click()
                 operation_status = True
             else:
                 print("{ERROR} - The required element with name: " + str(
@@ -430,7 +465,10 @@ class PgadminPage:
                     if self.check_if_element_exist_by_xpath(
                         "//div[@class='ajs-header'and text()='INTERNAL SERVER "
                             "ERROR']", 1):
-                        self.click_modal('OK')
+                        try:
+                            self.click_modal('OK')
+                        except Exception:
+                            pass
                         retry -= 1
                     else:
                         break
diff --git a/web/regression/feature_utils/tree_area_locators.py b/web/regression/feature_utils/tree_area_locators.py
index 3c4e8e5d4..e3dbb61ac 100644
--- a/web/regression/feature_utils/tree_area_locators.py
+++ b/web/regression/feature_utils/tree_area_locators.py
@@ -53,6 +53,10 @@ class TreeAreaLocators():
         "contains(text(),'Functions')]]]]]]]]]]/" \
         "following-sibling::ul/li/div//div/span[2]/span[2]"
 
+    sub_nodes_of_login_group_node = \
+        "//div[div[div[span[span[contains(text(),'Login/Group Roles')]]]]]" \
+        "/following::ul/li/div[@class='aciTreeLine']"
+
     @staticmethod
     def sub_nodes_of_a_server_node(server_name):
         xpath = "//div[div[div[span[span[contains(text(),'%s')]]]]]/" \
