mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fix some more feature tests:
1. Added an attribute 'data-click-counter' in query execute button which gets incremented once query button is clicked up to 9 and then reset to 0. This is added just to support automation. 2. Locator for login_group_role is added and used to expand tree. 3. Functions for enabling and disable auto_commit and auto_rollback are made more precise. 4. Some scrolling problem is addressed in view_data_dml_query test. 5. Handled the stale element reference exception in query_tool_journey_test
This commit is contained in:
committed by
Akshay Joshi
parent
dc47c8f898
commit
425cc2a966
@@ -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)
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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])
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user