diff --git a/web/pgadmin/feature_tests/pg_utilities_backup_restore_test.py b/web/pgadmin/feature_tests/pg_utilities_backup_restore_test.py index 1c89393d..4e11f994 100644 --- a/web/pgadmin/feature_tests/pg_utilities_backup_restore_test.py +++ b/web/pgadmin/feature_tests/pg_utilities_backup_restore_test.py @@ -83,6 +83,7 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest): self.page.find_by_css_selector( ".pg-bg-more-details").click() + backup_file = None # Check for XSS in Backup details if self.is_xss_check: self._check_detailed_window_for_xss('Backup') @@ -99,7 +100,6 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest): self.assertIn("pg_dump", str(command)) - backup_file = None if command: backup_file = command[int(command.find('--file')) + 8:int(command.find('--host')) - 2] diff --git a/web/pgadmin/utils/route.py b/web/pgadmin/utils/route.py index e45e06b7..d1c6ce63 100644 --- a/web/pgadmin/utils/route.py +++ b/web/pgadmin/utils/route.py @@ -56,7 +56,7 @@ class TestsGeneratorRegistry(ABCMeta): ABCMeta.__init__(cls, name, bases, d) @classmethod - def load_generators(cls, pkg_root, exclude_pkgs): + def load_generators(cls, pkg_root, exclude_pkgs, for_modules=[]): cls.registry = dict() @@ -64,6 +64,13 @@ class TestsGeneratorRegistry(ABCMeta): all_modules += find_modules(pkg_root, False, True) + # If specific modules are to be tested, exclude others + if len(for_modules) > 0: + all_modules = [module_name + for module_name in all_modules + for fmod in for_modules + if module_name.endswith(fmod)] + # Check for SERVER mode for module_name in all_modules: try: diff --git a/web/regression/README b/web/regression/README index 7e668cfd..6a68d36f 100644 --- a/web/regression/README +++ b/web/regression/README @@ -167,6 +167,14 @@ Python Tests: Example 2) Run test framework for 'database' node run 'python runtests.py --pkg browser.server_groups.servers.databases.tests' +- Execute test framework for certain modules of a test pkg + + Example 1) Run test framework for 'sqleditor' package and test_start_running_query module + run 'python runtests.py --pkg tools.sqleditor --modules test_start_running_query' + + Example 2) Run test framework for 'sqleditor' package and test_start_running_query,test_query_tool_fs_utils modules + run 'python runtests.py --pkg tools.sqleditor --modules test_start_running_query,test_query_tool_fs_utils' + - Exclude a package and its subpackages when running tests: Example: exclude feature tests but run all others: diff --git a/web/regression/feature_utils/pgadmin_page.py b/web/regression/feature_utils/pgadmin_page.py index 0c8f0fa3..42d51360 100644 --- a/web/regression/feature_utils/pgadmin_page.py +++ b/web/regression/feature_utils/pgadmin_page.py @@ -233,29 +233,39 @@ class PgadminPage: field.send_keys(str(field_content)) self.wait_for_input_field_content(field_name, field_content) - def fill_codemirror_area_with(self, field_content): + def fill_codemirror_area_with(self, field_content, input_keys=False): 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')]") + element = driver.find_element_by_css_selector( + "#output-panel .CodeMirror") if element.is_displayed() and element.is_enabled(): return element except (NoSuchElementException, WebDriverException): return False time.sleep(1) - WebDriverWait(self.driver, timeout=self.timeout, poll_frequency=0.01).\ - until(find_codemirror, "Timed out waiting for codemirror " - "to appear").click() + codemirror_ele = WebDriverWait( + self.driver, timeout=self.timeout, poll_frequency=0.01)\ + .until(find_codemirror, + "Timed out waiting for codemirror to appear") time.sleep(1) - action = ActionChains(self.driver) - action.send_keys(field_content) - action.perform() + codemirror_ele.click() + + # Use send keys if input_keys true, else you javascript to set content + if input_keys: + action = ActionChains(self.driver) + action.send_keys(field_content) + action.perform() + else: + self.driver.execute_script( + "arguments[0].CodeMirror.setValue(arguments[1]);" + "arguments[0].CodeMirror.setCursor(" + "arguments[0].CodeMirror.lineCount(),0);", + codemirror_ele, field_content) def click_tab(self, tab_name): WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable( diff --git a/web/regression/runtests.py b/web/regression/runtests.py index b023703d..116a0a16 100644 --- a/web/regression/runtests.py +++ b/web/regression/runtests.py @@ -233,9 +233,14 @@ def get_test_modules(arguments): if arguments['pkg'] is None or arguments['pkg'] == "all": TestsGeneratorRegistry.load_generators('pgadmin', exclude_pkgs) else: + for_modules = [] + if arguments['modules'] is not None: + for_modules = arguments['modules'].split(',') + TestsGeneratorRegistry.load_generators('pgadmin.%s' % arguments['pkg'], - exclude_pkgs) + exclude_pkgs, + for_modules) # Sort module list so that test suite executes the test cases sequentially module_list = TestsGeneratorRegistry.registry.items() @@ -266,6 +271,10 @@ def add_arguments(): '--default_browser', help='Executes the feature test in specific browser' ) + parser.add_argument( + '--modules', + help='Executes the feature test for specific modules in pkg' + ) arg = parser.parse_args() return arg