public inbox for [email protected]
help / color / mirror / Atom feedFrom: Shubham Agarwal <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: Re: Fixes for pgAdmin feature tests
Date: Wed, 20 Nov 2019 12:33:55 +0530
Message-ID: <CAKbCA9RyJzhmTW_7dMiSgMumjDx3tXQ3aJT2nHYeuT9FKJpO7A@mail.gmail.com> (raw)
In-Reply-To: <CANxoLDcYoAA8=0picZuccgfqXmyKVaT34iQRQjihtPoihb=nXQ@mail.gmail.com>
References: <CAKbCA9QmGWkR4rZEYFa_CYoWvSvDes6smUtjBHkpYDUCrBn09w@mail.gmail.com>
<CANxoLDdhJht3Dzsuyakst9t4UVrUwrGYbE+M_-xichAJpfAkvg@mail.gmail.com>
<CAKbCA9RQ8ebH4+XMZphrUfex4XfMfBZj2xGogUNyBqva2yPh4Q@mail.gmail.com>
<CANxoLDf49CjXGrU2Rg-wRcNLONEEMwbqqBM27uRT1NuRWb+cOg@mail.gmail.com>
<CAKbCA9TM0VsmjvEFtw-e2Tr77jCvPFx2ep=eXf49-1pkPZU9kA@mail.gmail.com>
<CANxoLDcYoAA8=0picZuccgfqXmyKVaT34iQRQjihtPoihb=nXQ@mail.gmail.com>
Hi Team,
PFA feature test fixture patch containing the following things:
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
Regards,
Shubham Agarwal
On Fri, Nov 15, 2019 at 6:03 PM Akshay Joshi <[email protected]>
wrote:
> Thanks, patch applied
>
> On Fri, Nov 15, 2019 at 5:59 PM Shubham Agarwal <
> [email protected]> wrote:
>
>> Hi Team,
>>
>> PFA feature test fixture patch containing the following fixes:
>> 1. Process watcher loading logs fix
>> 2. Auto commit/rollback issue in query_tool_tests
>> 3. Fixed the scrolling issue while verifying values in a table.
>> 4. Modified some functions in pgadmin_page.py
>>
>> On Wed, Nov 13, 2019 at 11:19 AM Akshay Joshi <
>> [email protected]> wrote:
>>
>>> Thanks, patch applied.
>>>
>>> On Tue, Nov 12, 2019 at 6:27 PM Shubham Agarwal <
>>> [email protected]> wrote:
>>>
>>>> Hi Team,
>>>> PFA patch containing some more fixes for random feature test failures.
>>>>
>>>> Thanks and regards,
>>>> Shubham Agarwal
>>>>
>>>> On Mon, Nov 11, 2019 at 10:55 AM Akshay Joshi <
>>>> [email protected]> wrote:
>>>>
>>>>> Thanks, patch applied with a minor change. Menu for 'Delete Drop'
>>>>> server has been changed to 'Remove Server' which causes all the test cases
>>>>> failing on my machine.
>>>>>
>>>>> On Mon, Nov 11, 2019 at 10:18 AM Shubham Agarwal <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> Hi Team,
>>>>>>
>>>>>> Attached is the patch containing fixes for the failed feature test
>>>>>> cases.
>>>>>> This patch contains-
>>>>>> 1. Newly created function for traversing the browser tree.
>>>>>> 2. Some synchronization issue fixes.
>>>>>> 3. Modified locators.
>>>>>> 4. Test cases fix for the recent commits.
>>>>>>
>>>>>> --
>>>>>> Thanks & Regards,
>>>>>> Shubham Agarwal
>>>>>> EnterpriseDB Corporation
>>>>>>
>>>>>> The Postgres Database Company
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> *Thanks & Regards*
>>>>> *Akshay Joshi*
>>>>>
>>>>> *Sr. Software Architect*
>>>>> *EnterpriseDB Software India Private Limited*
>>>>> *Mobile: +91 976-788-8246*
>>>>>
>>>>
>>>>
>>>> --
>>>> Thanks & Regards,
>>>> Shubham Agarwal
>>>> EnterpriseDB Corporation
>>>>
>>>> The Postgres Database Company
>>>>
>>>
>>>
>>> --
>>> *Thanks & Regards*
>>> *Akshay Joshi*
>>>
>>> *Sr. Software Architect*
>>> *EnterpriseDB Software India Private Limited*
>>> *Mobile: +91 976-788-8246*
>>>
>>
>>
>> --
>> Thanks & Regards,
>> Shubham Agarwal
>> EnterpriseDB Corporation
>>
>> The Postgres Database Company
>>
>
>
> --
> *Thanks & Regards*
> *Akshay Joshi*
>
> *Sr. Software Architect*
> *EnterpriseDB Software India Private Limited*
> *Mobile: +91 976-788-8246*
>
--
Thanks & Regards,
Shubham Agarwal
EnterpriseDB Corporation
The Postgres Database Company
Attachments:
[application/octet-stream] feature_test_fix_v4.patch (15.9K, 3-feature_test_fix_v4.patch)
download | inline diff:
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')]]]]]/" \
view thread (12+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: Fixes for pgAdmin feature tests
In-Reply-To: <CAKbCA9RyJzhmTW_7dMiSgMumjDx3tXQ3aJT2nHYeuT9FKJpO7A@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox