What are Desired Capabilities in Selenium


The desired capability is a series of key-value pairs that stores the browser properties like browser name, browser version, the path of the browser driver in the system, etc. to determine the behavior of the browser at run time. Not all server implementations will support every WebDriver feature. The client and server should use JSON objects with the properties when describing which features a user requests that a session support. If a session cannot support a capability that is requested in the desired capabilities, no error is thrown; a read-only capabilities object is returned that indicates the capabilities the session actually supports.
  • Desired capability is used to configure the driver instance of Selenium WebDriver.
  • Used to configure driver instance like FirefoxDriver, ChromeDriver, InternetExplorerDriver by using desired capabilities.
  • Used in mobile application automation, where the browser properties and the device properties are set.
  • Used in Selenium grid when we want to run the test cases on a different browser with different operating systems and versions.
Methods present in desired capabilities include:
public java.lang.String getBrowserName()
public void setBrowserName(java.lang.String browserName)
public java.lang.String getVersion()
public void setVersion(java.lang.String version)
public Platform getPlatform()
public Platform setPlatform()
public java.lang.Object getCapability(java.lang.String capabilityName)
public void setCapability(java.lang.String capabilityName,boolean value)

Useful links: GitHub

No comments:

Post a Comment