1.

What are Desired capabilities?

Answer»

The desired capability stores the browser properties like browser NAME, browser version, the path of the browser driver in the system, etc in a series of key/value pairs, to determine the behaviour of the browser at RUN time.

You can also use the Desired capability to configure the driver instance of Selenium WebDriver like FirefoxDriver, ChromeDriver, InternetExplorerDriver.

Every Testing scenario is executed on a specific testing environment and this testing environment can be a web browser, Mobile device, mobile emulator, mobile simulator, etc.

The Desired Capabilities Class TELLS WebDriver, which environment you going to use in the test script.

The setCapability method of the DesiredCapabilities Class can be used in Selenium Grid to perform a parallel execution on different machine configurations.

Desired capability is used to set the browser properties, Platform Name that is used when executing the test cases.

In the case of mobile automation, we perform the tests on different mobile devices, the Mobile Platform ex. iOS, Android Platform Version Ex. 3.x,4.x in Android can be set.

Desired Capabilities are more USEFUL in mobile application automation, where the browser properties and the device properties can be set. And in Selenium grid to run the test cases on a different browser along with different operating systems and versions.

Example-

// Create a new OBJECT of DesiredCapabilities class. DesiredCapabilities capabilities = new DesiredCapabilities(); // set the android deviceName desiredcapability. capabilities.setCapability("deviceName", "your Device Name"); // Set the BROWSER_NAME desiredcapability. capabilities.setCapability(CapabilityType.BROWSER_NAME, "Chrome"); // Set the android VERSION desiredcapability. capabilities.setCapability(CapabilityType.VERSION, "5.1"); // Set the android platformName desired capability. capabilities.setCapability("platformName", "Android");


Discussion

No Comment Found