def RunTests(chrome_path, chromedriver_path, profile_path, environment_passwords_path, enable_automatic_password_saving, environment_numeric_level, log_to_console, environment_log_file, environment_tested_websites, tests=None): """Runs the the tests Args: chrome_path: The chrome binary file. chromedriver_path: The chromedriver binary file. profile_path: The chrome testing profile folder. environment_passwords_path: The usernames and passwords file. enable_automatic_password_saving: If True, the passwords are going to be saved without showing the prompt. environment_numeric_level: The log verbosity. log_to_console: If True, the debug logs will be shown on the console. environment_log_file: The file where to store the log. If it's empty, the log is not stored. environment_tested_websites: One of the TypeOfTestedWebsites values, indicating which group of tests to run. tests: Specifies which tests to run. Ignored unless |environment_tested_websites| is equal to LIST_OF_TESTS. Returns: The results of tests as list of TestResults. Raises: Exception: An exception is raised if one of the tests fails. """ environment = Environment(chrome_path, chromedriver_path, profile_path, environment_passwords_path, enable_automatic_password_saving, environment_numeric_level, log_to_console, environment_log_file) # Test which care about the save-password prompt need the prompt # to be shown. Automatic password saving results in no prompt. run_prompt_tests = not enable_automatic_password_saving Tests(environment) if environment_tested_websites == TypeOfTestedWebsites.ALL_TESTS: environment.AllTests(run_prompt_tests) elif environment_tested_websites == TypeOfTestedWebsites.DISABLED_TESTS: environment.DisabledTests(run_prompt_tests) elif environment_tested_websites == TypeOfTestedWebsites.LIST_OF_TESTS: environment.Test(tests, run_prompt_tests) elif environment_tested_websites == TypeOfTestedWebsites.ENABLED_TESTS: environment.WorkingTests(run_prompt_tests) else: raise Exception("Error: |environment_tested_websites| has to be one of the" "TypeOfTestedWebsites values") environment.Quit() return environment.tests_results
def RunTests(chrome_path, chromedriver_path, profile_path, environment_passwords_path, enable_automatic_password_saving, environment_numeric_level, log_to_console, environment_log_file, all_tests, tests): """Runs the the tests Args: chrome_path: The chrome binary file. chromedriver_path: The chromedriver binary file. profile_path: The chrome testing profile folder. environment_passwords_path: The usernames and passwords file. enable_automatic_password_saving: If True, the passwords are going to be saved without showing the prompt. environment_numeric_level: The log verbosity. log_to_console: If True, the debug logs will be shown on the console. environment_log_file: The file where to store the log. If it's empty, the log is not stored. all_tests: If True, all the tests are going to be ran. tests: A list of the names of the WebsiteTests that are going to be tested. Raises: Exception: An exception is raised if the one of the tests fails. """ environment = Environment(chrome_path, chromedriver_path, profile_path, environment_passwords_path, enable_automatic_password_saving, environment_numeric_level, log_to_console, environment_log_file) # Test which care about the save-password prompt need the prompt # to be shown. Automatic password saving results in no prompt. run_prompt_tests = not enable_automatic_password_saving Tests(environment) if all_tests: environment.AllTests(run_prompt_tests) elif tests: environment.Test(tests, run_prompt_tests) else: environment.WorkingTests(run_prompt_tests) environment.Quit()
def RunTest(chrome_path, chromedriver_path, profile_path, environment_passwords_path, website_test_name, test_case_name): """Runs the test for the specified website. Args: chrome_path: The chrome binary file. chromedriver_path: The chromedriver binary file. profile_path: The chrome testing profile folder. environment_passwords_path: The usernames and passwords file. website_test_name: Name of the website to test (refer to keys in all_tests above). Returns: The results of the test as list of TestResults. Raises: Exception: An exception is raised if one of the tests for the website fails, or if the website name is not known. """ enable_automatic_password_saving = ( test_case_name == "SaveAndAutofillTest") environment = Environment(chrome_path, chromedriver_path, profile_path, environment_passwords_path, enable_automatic_password_saving) try: if website_test_name in all_tests: environment.AddWebsiteTest(all_tests[website_test_name]) else: raise Exception( "Test name {} is unknown.".format(website_test_name)) environment.RunTestsOnSites(test_case_name) return environment.tests_results finally: environment.Quit()