selenium.webdriver.common.desired_capabilities

The Desired Capabilities implementation.

class selenium.webdriver.common.desired_capabilities.DesiredCapabilities[source]

Set of default supported desired capabilities.

Use this as a starting point for creating a desired capabilities object for requesting remote webdrivers for connecting to selenium server or selenium grid.

Usage Example:

from selenium import webdriver

selenium_grid_url = "http://198.0.0.1:4444/wd/hub"

# Create a desired capabilities object as a starting point.
capabilities = DesiredCapabilities.FIREFOX.copy()
capabilities['platform'] = "WINDOWS"
capabilities['version'] = "10"

# Instantiate an instance of Remote WebDriver with the desired capabilities.
driver = webdriver.Remote(desired_capabilities=capabilities,
                          command_executor=selenium_grid_url)

Note: Always use ‘.copy()’ on the DesiredCapabilities object to avoid the side effects of altering the Global class instance.

ANDROID = {'platform': 'ANDROID', 'version': '', 'browserName': 'android'}
CHROME = {'platform': 'ANY', 'version': '', 'browserName': 'chrome'}
EDGE = {'platform': 'WINDOWS', 'version': '', 'browserName': 'MicrosoftEdge'}
FIREFOX = {'acceptInsecureCerts': True, 'browserName': 'firefox', 'marionette': True}
HTMLUNIT = {'platform': 'ANY', 'version': '', 'browserName': 'htmlunit'}
HTMLUNITWITHJS = {'platform': 'ANY', 'version': 'firefox', 'browserName': 'htmlunit', 'javascriptEnabled': True}
INTERNETEXPLORER = {'platform': 'WINDOWS', 'version': '', 'browserName': 'internet explorer'}
IPAD = {'platform': 'MAC', 'version': '', 'browserName': 'iPad'}
IPHONE = {'platform': 'MAC', 'version': '', 'browserName': 'iPhone'}
OPERA = {'platform': 'ANY', 'version': '', 'browserName': 'opera'}
PHANTOMJS = {'platform': 'ANY', 'version': '', 'browserName': 'phantomjs', 'javascriptEnabled': True}
SAFARI = {'platform': 'MAC', 'version': '', 'browserName': 'safari'}
WEBKITGTK = {'platform': 'ANY', 'version': '', 'browserName': 'MiniBrowser'}

This Page