Desired Capabilities in Selenium WebDriver

Hello friends! in this post we will be studying about Desired Capabilities. Many a times during automation, we may need to work on a particular session of browser or work with a browser having some specific configurable properties set or unset. Selenium web driver provides certain browser specific properties known as Desired Capabilities.

What are Desired Capabilities?

Desired Capabilities are a set of properties used to configure a particular instance of browser. We have both browser independent capabilties like browserName, version, acceptSslCerts etc as well browser specific capabilities like firefox_binary for Mozilla Firefox, chromeOptions for setting Chrome specific desired capabilties.

Setting Desired Capabilities in Selenium

The Desired Capabilities class provides a setCapabilityMethod() to set the different capabilities in a browser like accepting SSL certificates, enabling javascript, querying the browser location is allowed or not etc.
Code snippet to set a capability to a browser instance -

//Specifying desired capabilities for Chrome browser
DesiredCapabilities acceptSSLCertificate =;

//Setting capability to accept SSL certificates
acceptSSLCertificate.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);

//Binding the capabilities to a new instance of chrome browser
WebDriver driver = new ChromeDriver(acceptSSLCertificate);


Some of the capabilities common to all browsers are -

  • acceptSslCerts-
    Constant Field - CapabilityType.ACCEPT_SSL_CERTS
    For enabling or a disabling a browser session to accept the SSL certificates by default.

  • applicationCacheEnabled-
    Constant Field - CapabilityType.SUPPORTS_APPLICATION_CACHE
    For checking if the browser instance is capable of interacting with application cache.

  • cssSelectorsEnabled-
    Constant Field - CapabilityType.SUPPORTS_FINDING_BY_CSS
    For checking if the use of CSS selector for locating web elements is enabled or not.

  • javascriptEnabled-
    Constant Field - CapabilityType.SUPPORTS_JAVASCRIPT
    For checking if javascript execution is enabled or not in the browser instance.

  • takesScreenshot-
    Constant Field - CapabilityType.TAKES_SCREENSHOT
    For checking if the take screenshot ability is enabled or not.

  • webStorageEnabled-
    Constant Field - CapabilityType.SUPPORTS_WEB_STORAGE
    For checking if the browser instance is capable of interacting with storage objects.

  • handlesAlert-
    Constant Field - CapabilityType.SUPPORTS_ALERTS
    For checking if the browser instance is capable of handling window pop-ups.