From 95f63f6af89ae07b940a07add161e91479a907fd Mon Sep 17 00:00:00 2001 From: Yogesh Mahajan Date: Wed, 22 Jun 2022 17:47:09 +0530 Subject: [PATCH] Fixed feature tests. --- web/pgadmin/feature_tests/query_tool_tests.py | 33 ++++++++----------- web/regression/feature_utils/pgadmin_page.py | 15 ++++++--- .../python_test_utils/test_utils.py | 4 ++- web/regression/runtests.py | 6 ++-- 4 files changed, 31 insertions(+), 27 deletions(-) diff --git a/web/pgadmin/feature_tests/query_tool_tests.py b/web/pgadmin/feature_tests/query_tool_tests.py index 3915a29e7..6c0c305a4 100644 --- a/web/pgadmin/feature_tests/query_tool_tests.py +++ b/web/pgadmin/feature_tests/query_tool_tests.py @@ -118,9 +118,9 @@ class QueryToolFeatureTest(BaseFeatureTest): # this will set focus to correct iframe. self.page.fill_codemirror_area_with('') - explain_op = self.page.find_by_css_selector( - QueryToolLocators.btn_explain_options_dropdown) - explain_op.click() + self.page.retry_click( + (By.CSS_SELECTOR, QueryToolLocators.btn_explain_options_dropdown), + (By.CSS_SELECTOR, QueryToolLocators.btn_explain_verbose)) # disable Explain options and auto rollback only if they are enabled. for op in (QueryToolLocators.btn_explain_verbose, @@ -261,17 +261,15 @@ SELECT generate_series(1, 1000) as id order by id desc""" self.page.fill_codemirror_area_with(query) - explain_op = self.page.find_by_css_selector( - QueryToolLocators.btn_explain_options_dropdown) - explain_op.click() + self.page.retry_click( + (By.CSS_SELECTOR, QueryToolLocators.btn_explain_options_dropdown), + (By.CSS_SELECTOR, QueryToolLocators.btn_explain_verbose)) # disable Explain options and auto rollback only if they are enabled. for op in (QueryToolLocators.btn_explain_verbose, QueryToolLocators.btn_explain_costs): self.page.find_by_css_selector(op).click() - explain_op.click() - self.page.find_by_css_selector( QueryToolLocators.btn_explain).click() @@ -299,17 +297,15 @@ SELECT generate_series(1, 1000) as id order by id desc""" self.page.fill_codemirror_area_with(query) - explain_op = self.page.find_by_css_selector( - QueryToolLocators.btn_explain_options_dropdown) - explain_op.click() + self.page.retry_click( + (By.CSS_SELECTOR, QueryToolLocators.btn_explain_options_dropdown), + (By.CSS_SELECTOR, QueryToolLocators.btn_explain_verbose)) # disable Explain options and auto rollback only if they are enabled. for op in (QueryToolLocators.btn_explain_buffers, QueryToolLocators.btn_explain_timing): self.page.find_by_css_selector(op).click() - explain_op.click() - self.page.find_by_css_selector( QueryToolLocators.btn_explain_analyze).click() @@ -685,9 +681,10 @@ SELECT 1, pg_sleep(300)""" self.page.fill_codemirror_area_with( "SELECT count(*) FROM pg_catalog.pg_class;") - explain_op = self.page.find_by_css_selector( - QueryToolLocators.btn_explain_options_dropdown) - explain_op.click() + + self.page.retry_click( + (By.CSS_SELECTOR, QueryToolLocators.btn_explain_options_dropdown), + (By.CSS_SELECTOR, QueryToolLocators.btn_explain_verbose)) # disable Explain options and only enable COST option for op in (QueryToolLocators.btn_explain_verbose, @@ -702,9 +699,7 @@ SELECT 1, pg_sleep(300)""" QueryToolLocators.btn_explain_costs) cost_btn.click() - # close explain options - explain_op.click() - + # close explain options not required self.page.find_by_css_selector( QueryToolLocators.btn_explain_analyze).click() diff --git a/web/regression/feature_utils/pgadmin_page.py b/web/regression/feature_utils/pgadmin_page.py index c1d1b3064..139af3c86 100644 --- a/web/regression/feature_utils/pgadmin_page.py +++ b/web/regression/feature_utils/pgadmin_page.py @@ -39,6 +39,7 @@ class PgadminPage: # pgAdmin related methods def login_to_app(self, user_detail): + self.driver.switch_to.default_content() if not (self.check_if_element_exist_by_xpath( '//a[@id="navbar-user"]', 1)): user_edt_box_el = self.driver.find_element_by_name('email') @@ -253,11 +254,14 @@ class PgadminPage: css_selector_of_option) if menu_option.get_attribute('data-checked') == 'false': while retry > 0: - menu_option.click() - time.sleep(0.2) - if menu_option.get_attribute('data-checked') == 'true': - break - else: + try: + menu_option.click() + time.sleep(0.2) + if menu_option.get_attribute('data-checked') == 'true': + break + else: + retry -= 1 + except Exception: retry -= 1 if option == 'auto_commit': @@ -618,6 +622,7 @@ class PgadminPage: database_node = \ self.check_if_element_exists_with_scroll(database_node_xpath) if database_node: + database_node.click() self.driver.execute_script( self.js_executor_scrollintoview_arg, database_node) if self.check_if_element_exist_by_xpath( diff --git a/web/regression/python_test_utils/test_utils.py b/web/regression/python_test_utils/test_utils.py index db4192476..1e14219bf 100644 --- a/web/regression/python_test_utils/test_utils.py +++ b/web/regression/python_test_utils/test_utils.py @@ -1384,7 +1384,7 @@ def launch_url_in_browser(driver_instance, url, title='pgAdmin 4', timeout=50): raise WebDriverException(exception_msg) -def get_remote_webdriver(hub_url, browser, browser_ver, test_name): +def get_remote_webdriver(hub_url, browser, browser_ver, test_name, url_client): """ This functions returns remote web-driver instance created in selenoid machine. @@ -1421,6 +1421,8 @@ def get_remote_webdriver(hub_url, browser, browser_ver, test_name): elif browser == 'chrome': options = Options() options.add_argument("--window-size=1280,1024") + options.add_argument( + '--unsafely-treat-insecure-origin-as-secure=' + url_client) desired_capabilities["browserName"] = "chrome" driver_local = webdriver.Remote( command_executor=hub_url, diff --git a/web/regression/runtests.py b/web/regression/runtests.py index 083402895..14e8cabd1 100644 --- a/web/regression/runtests.py +++ b/web/regression/runtests.py @@ -601,7 +601,8 @@ def run_parallel_tests(url_client, servers_details, parallel_tests_lists, test_utils.get_remote_webdriver(hub_url, name_of_browser, version_of_browser, - ser['name']) + ser['name'], + url_client) # Launch client url in browser test_utils.launch_url_in_browser( driver_object, url_client, timeout=60) @@ -659,7 +660,8 @@ def run_sequential_tests(url_client, servers_details, sequential_tests_lists, driver_object = test_utils.get_remote_webdriver(hub_url, name_of_browser, version_of_browser, - "Sequential_Tests") + "Sequential_Tests", + url_client) # Launch client url in browser test_utils.launch_url_in_browser(driver_object, url_client)