DesiredCapabilities in Selenium WebDriver

0 votes
Can someone please tell me what's the use of DesiredCapabilities in WebDriver, when do we use it and how? Kindly explain with an example?
Apr 4, 2018 in Selenium by nitinrawat895
• 10,710 points
2,685 views

1 answer to this question.

0 votes

DesiredCapabilities is a class in org.openqa.selenium.remote.DesiredCapabilities package used for setting the properties of a browser such as BrowserName, Platform, Version of Browser, etc. A typical usecase would be to set the path of FirefoxDriver for testing. DesiredCapabilities class is also used when we need to use Selenium Grid for executing mutiple TestCases on multiple Systems with diff browsers, and diff versions and diff OSs.
Example:-

// To Create a new object of DesiredCapabilities class.
DesiredCapabilities capabilities = new DesiredCapabilities();

// To set the android deviceName desiredcapability.
capabilities.setCapability("deviceName", "your Device Name");

// To set the BROWSER_NAME desiredcapability.
capabilities.setCapability(CapabilityType.BROWSER_NAME, "Chrome");

// To set the android VERSION desiredcapability.
capabilities.setCapability(CapabilityType.VERSION, "5.1");

// To set the android platformName desired capability.
capabilities.setCapability("platformName", "Android");
answered Apr 4, 2018 by nsv999
• 5,110 points

Related Questions In Selenium

+2 votes
4 answers

sendKeys() not working in Selenium Webdriver

this work for me you should update your ...READ MORE

answered Aug 27 in Selenium by Afif
13,947 views
0 votes
1 answer

Double click a record in a grid using Selenium webdriver

Try Actions class to perform this Actions action ...READ MORE

answered Mar 29, 2018 in Selenium by Damon Salvatore
• 5,510 points
1,138 views
0 votes
2 answers

Can anyone help me that how to run Selenium WebDriver test cases in Chrome?

You first need to download chrome driver ...READ MORE

answered Aug 26 in Selenium by Abha
• 27,180 points
308 views
0 votes
1 answer
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,110 points
965 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
1,125 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
868 views
0 votes
3 answers

How to specify "ENTER" button functionality in Selenium WebDriver code?

using OpenQA.Selenium.Interactions; Actions builder = new Actions(driver); ...READ MORE

answered Feb 12 in Selenium by anonymous
11,455 views
0 votes
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,110 points
2,288 views