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 WebDriverTestCase subclasses to generate a test suite for

  • browser_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>.config

  • browserstack – (Default = False) If True, configure generated test cases to run on BrowserStack instead of locally. Need to provide config_module with appropriately configured BrowserStackConfig class if set to True

  • headless – (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.TestSuite object 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 WebDriverTestCase subclass

Parameters
  • base_class – The WebDriverTestCase subclass to generate test classes for

  • browser_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>.config

  • browserstack – (Default = False) If True, configure generated test cases to run on BrowserStack instead of locally. Need to provide config_module with appropriately configured BrowserStackConfig class if set to True

  • headless – (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_classWebDriverTestCase containing test functions

  • browser_test_class – The driver-specific implementation of WebDriverTestCase to generate a test for

  • config_module – (Optional) The module object for <test_project>.config

  • browserstack – (Default = False) If True, configure generated test cases to run on BrowserStack instead of locally. Need to provide config_module with appropriately configured BrowserStackConfig class if set to True

  • headless – (Default = False) If True, configure driver to run tests in a headless browser

Returns

Test case class with tests from base_class and driver configurations from browser_test_class. If browserstack is set to True, returned class will have appropriate attributes configured for BrowserStack execution. If headless is 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_BS and COMMAND_EXECUTOR attributes 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_case class with ENABLE_HEADLESS attribute configured