webdriver_test_tools.config.webdriver module

class webdriver_test_tools.config.webdriver.WebDriverConfig[source]

Configurations for webdriver

LOG_PATH = os.path.join(os.path.dirname(os.path.abspath(webdriver_test_tools.__file__)), 'log')

Path to the log directory. Defaults to the log subdirectory in the webdriver_test_tools package root directory

SCREENSHOT_PATH = os.path.join(os.path.dirname(os.path.abspath(webdriver_test_tools.__file__)), 'screenshot')

Path to the screenshot directory. Defaults to the screenshot subdirectory in the webdriver_test_tools package root directory

SCREENSHOT_FILENAME_FORMAT = '{date}/{time}-{test}-{browser}.png'

Format string used to determine filenames for screenshots (relative to WebDriverConfig.SCREENSHOT_PATH). The format string can include the following parameters:

  • {date}: Replaced with the date the screenshot was taken (YYYY-MM-DD)

  • {time}: Replaced with the time the screenshot was taken (HHMMSS)

  • {test}: Replaced with the test method running when screenshot was taken

  • {browser}: Replaced with the browser used when screenshot was taken

The format string can include ‘/’ directory separators to save screenshots in subdirectories of WebDriverConfig.SCREENSHOT_PATH.

DEFAULT_ASSERTION_TIMEOUT = 10

Default number of seconds for WebDriverTestCase assertion methods to wait for expected conditions to occur before test fails

FIREFOX_KWARGS = {}

Keyword args for webdriver.Firefox()

CHROME_KWARGS = {}

Keyword args for webdriver.Chrome()

SAFARI_KWARGS = {}

Keyword args for webdriver.Safari()

IE_KWARGS = {}

Keyword args for webdriver.Ie()

EDGE_KWARGS = {}

Keyword args for webdriver.Edge()

CHROME_MOBILE_EMULATION = {'deviceName': 'Pixel 2'}

Dictionary with ‘mobileEmulation’ options for Chrome

CHROME_HEADLESS_ARGS = ['--window-size=1920x1080']

Command line arguments to use in addition to the --headless flag

FIREFOX_HEADLESS_ARGS = []

Command line arguments to use in addition to the -headless flag

classmethod get_firefox_driver(headless=False)[source]

Returns webdriver.Firefox object using FIREFOX_KWARGS and LOG_PATH to initialize

Parameters

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

classmethod get_chrome_driver(headless=False)[source]

Returns webdriver.Chrome object using CHROME_KWARGS and LOG_PATH to initialize

Parameters

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

classmethod get_safari_driver()[source]

Returns webdriver.Safari object using SAFARI_KWARGS to initialize

classmethod get_ie_driver()[source]

Returns webdriver.Ie object using IE_KWARGS and LOG_PATH to initialize

classmethod get_edge_driver()[source]

Returns webdriver.Edge object using EDGE_KWARGS and LOG_PATH to initialize

classmethod get_chrome_mobile_driver(headless=False)[source]

Returns webdriver.Chrome object using CHROME_KWARGS, LOG_PATH, and CHROME_MOBILE_EMULATION to initialize

Parameters

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

classmethod new_screenshot_file(browser_name, test_name, makedirs=True)[source]

Return the full path and filename for the screenshot

The filename is determined by the format set in WebDriverConfig.SCREENSHOT_FILENAME_FORMAT. If the format doesn’t end with ‘.png’, the extension will be appended to the resulting filename

Parameters
  • browser_name – Name of the browser (for screenshot filename)

  • test_name – Name of the current test (for screenshot filename)

  • makedirs – (Default = True) If True, create any subdirectories of screenshot/ if they don’t already exist

Returns

Filename for the screenshot