diff --git a/web/pgadmin/feature_tests/pg_datatype_validation_test.py b/web/pgadmin/feature_tests/pg_datatype_validation_test.py index fdc65a58..69b12f30 100644 --- a/web/pgadmin/feature_tests/pg_datatype_validation_test.py +++ b/web/pgadmin/feature_tests/pg_datatype_validation_test.py @@ -6,7 +6,6 @@ # This software is released under the PostgreSQL Licence # ########################################################################## - from selenium.webdriver import ActionChains from selenium.common.exceptions import TimeoutException from selenium.webdriver.support.ui import WebDriverWait @@ -90,30 +89,28 @@ class PGDataypeFeatureTest(BaseFeatureTest): self.page.driver.find_element_by_link_text("Tools").click() self.page.find_by_partial_link_text("Query Tool").click() + + self.page.fill_codemirror_area_with(query) + self.page.find_by_id("btn-flash").click() wait = WebDriverWait(self.page.driver, 5) - element = wait.until(EC.frame_to_be_available_and_switch_to_it((By.TAG_NAME, 'iframe'))) - - if element: - self.page.fill_codemirror_area_with(query) - self.page.find_by_id("btn-flash").click() - wait.until(EC.presence_of_element_located( - (By.XPATH, "//*[@id='0']//*[@id='datagrid']/div[5]/div/div[1]/div[2]/span"))) - - # For every sample data-type value, check the expected output. - cnt = 2 - for val in expected_output: - try: - source_code = self.page.find_by_xpath( - "//*[@id='0']//*[@id='datagrid']/div[5]/div/div[1]/div[" + str(cnt) + "]/span" - ).get_attribute('innerHTML') - - PGDataypeFeatureTest.check_result( - source_code, - expected_output[cnt - 2] - ) - cnt += 1 - except TimeoutException: - assert False, "{0} does not match with {1}".format(val, expected_output[cnt]) + wait.until(EC.presence_of_element_located( + (By.XPATH, "//*[@id='0']//*[@id='datagrid']/div[5]/div/div[1]/div[2]/span"))) + + # For every sample data-type value, check the expected output. + cnt = 2 + for val in expected_output: + try: + source_code = self.page.find_by_xpath( + "//*[@id='0']//*[@id='datagrid']/div[5]/div/div[1]/div[" + str(cnt) + "]/span" + ).get_attribute('innerHTML') + + PGDataypeFeatureTest.check_result( + source_code, + expected_output[cnt - 2] + ) + cnt += 1 + except TimeoutException: + assert False, "{0} does not match with {1}".format(val, expected_output[cnt]) @staticmethod def check_result(source_code, string_to_find): diff --git a/web/pgadmin/feature_tests/xss_checks_panels_and_query_tool_test.py b/web/pgadmin/feature_tests/xss_checks_panels_and_query_tool_test.py index 526d4e76..d59e8ac3 100644 --- a/web/pgadmin/feature_tests/xss_checks_panels_and_query_tool_test.py +++ b/web/pgadmin/feature_tests/xss_checks_panels_and_query_tool_test.py @@ -149,8 +149,6 @@ class CheckForXssFeatureTest(BaseFeatureTest): def _check_xss_in_query_tool(self): self.page.driver.find_element_by_link_text("Tools").click() self.page.find_by_partial_link_text("Query Tool").click() - time.sleep(3) - self.page.driver.switch_to.frame(self.page.driver.find_element_by_tag_name('iframe')) self.page.fill_codemirror_area_with("select ''") time.sleep(1) self.page.find_by_id("btn-flash").click() diff --git a/web/regression/feature_utils/pgadmin_page.py b/web/regression/feature_utils/pgadmin_page.py index b9abe7ca..30f710eb 100644 --- a/web/regression/feature_utils/pgadmin_page.py +++ b/web/regression/feature_utils/pgadmin_page.py @@ -26,7 +26,7 @@ class PgadminPage: def __init__(self, driver, app_config): self.driver = driver self.app_config = app_config - self.timeout = 30 + self.timeout = 20 self.app_start_timeout = 60 def reset_layout(self): @@ -118,14 +118,27 @@ class PgadminPage: # For long text, if we try to execute send_keys and perform back to back, then the actions are # not executed properly as the driver can send only 50 to 60 characters. To avoid this, sleep # on the basis of content length. - self.find_by_xpath( - "//pre[contains(@class,'CodeMirror-line')]/../../../*[contains(@class,'CodeMirror-code')]").click() + def find_codemirror(driver): + try: + driver.switch_to.default_content() + driver.switch_to_frame(driver.find_element_by_tag_name("iframe")) + element = driver.find_element_by_xpath( + "//pre[contains(@class,'CodeMirror-line')]/../../../*[contains(@class,'CodeMirror-code')]") + if element.is_displayed() and element.is_enabled(): + return element + except (NoSuchElementException, WebDriverException): + return False + + WebDriverWait(self.driver, timeout=self.timeout, poll_frequency=0.01).\ + until(find_codemirror, "Timed out waiting for codemirror to appear").\ + click() + time.sleep(1) + action = ActionChains(self.driver) action.send_keys(field_content) + action.perform() sleep_time = math.ceil(len(field_content) / 50) time.sleep(sleep_time) - action.perform() - time.sleep(1) def click_tab(self, tab_name): self.find_by_xpath("//*[contains(@class,'wcTabTop')]//*[contains(@class,'wcPanelTab') "