webdriver_test_tools.project.test_factory module¶
Functions for generating test cases
-
webdriver_test_tools.project.test_factory.generate_browser_test_suite(test_case_list, browser_test_classes=None, test_class_map=None, skip_class_map=None, config_module=None, browserstack=False, headless=False)[source]¶ Generates test cases for multiple browsers and returns a TestSuite with all of the new tests
- Parameters
test_case_list – A list of
WebDriverTestCasesubclasses to generate a test suite forbrowser_test_classes – (Optional) If specified, only generate tests using the browser classes in this list. If not specified, tests will be generated for each available browser test case class.
test_class_map – (Optional) Dictionary mapping test case names to a list of test functions. If the list is empty, all test functions will be loaded
skip_class_map – (Optional) Dictionary mapping test case names to a list of test functions. If the list is empty, entire class will be skipped
config_module – (Optional) The module object for
<test_project>.configbrowserstack – (Default = False) If True, configure generated test cases to run on BrowserStack instead of locally. Need to provide
config_modulewith appropriately configuredBrowserStackConfigclass if set to Trueheadless – (Default = False) If True, configure driver to run tests in a headless browser. Tests will only be generated for drivers that support running headless browsers
- Returns
unittest.TestSuiteobject with generated tests for each browser
-
webdriver_test_tools.project.test_factory.generate_browser_test_cases(base_class, browser_test_classes=None, config_module=None, browserstack=False, headless=False)[source]¶ Generate test cases for each browser from a
WebDriverTestCasesubclass- Parameters
base_class – The
WebDriverTestCasesubclass to generate test classes forbrowser_test_classes – (Optional) If specified, only generate tests using the browser classes specified in this list. If not specified, tests will be generated for each available browser test case class
config_module – (Optional) The module object for
<test_project>.configbrowserstack – (Default = False) If True, configure generated test cases to run on BrowserStack instead of locally. Need to provide
config_modulewith appropriately configuredBrowserStackConfigclass if set to Trueheadless – (Default = False) If True, configure driver to run tests in a headless browser
- Returns
List of generated test case classes for each browser
-
webdriver_test_tools.project.test_factory.generate_browser_test_case(base_class, browser_test_class, config_module=None, browserstack=False, headless=False)[source]¶ Generates a browser-specific test case class from a generic
WebDriverTestCase- Parameters
base_class –
WebDriverTestCasecontaining test functionsbrowser_test_class – The driver-specific implementation of
WebDriverTestCaseto generate a test forconfig_module – (Optional) The module object for
<test_project>.configbrowserstack – (Default = False) If True, configure generated test cases to run on BrowserStack instead of locally. Need to provide
config_modulewith appropriately configuredBrowserStackConfigclass if set to Trueheadless – (Default = False) If True, configure driver to run tests in a headless browser
- Returns
Test case class with tests from
base_classand driver configurations frombrowser_test_class. Ifbrowserstackis set to True, returned class will have appropriate attributes configured for BrowserStack execution. Ifheadlessis set to True, returned class will have appropriate attributes configured for headless browser execution.
-
webdriver_test_tools.project.test_factory.enable_browserstack(browser_test_case, config_module)[source]¶ Enable BrowserStack test execution for a class
- Parameters
browser_test_case – Browser test case class to configure for BrowserStack usage
config_module – The module object for
<test_project>.config
- Returns
browser_test_case class with
ENABLE_BSandCOMMAND_EXECUTORattributes configured appropriately
-
webdriver_test_tools.project.test_factory.enable_headless(browser_test_case)[source]¶ Enable headless browser test execution for a class
- Parameters
browser_test_case – Browser test case class to configure for BrowserStack usage
- Returns
browser_test_caseclass withENABLE_HEADLESSattribute configured