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
• 11,380 points
5,576 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,500 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, 2019 in Selenium by Afif
30,232 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 30, 2018 in Selenium by Damon Salvatore
• 5,980 points
5,404 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, 2019 in Selenium by Abha
• 28,140 points
2,012 views
0 votes
1 answer
0 votes
2 answers

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,500 points
13,776 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,188 views
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,910 points
7,265 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,902 views
0 votes
6 answers

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

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

answered Feb 13, 2019 in Selenium by anonymous
96,267 views
+1 vote
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,500 points
8,408 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP