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
• 9,070 points
1,276 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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,030 points

Related Questions In Selenium

+1 vote
3 answers

sendKeys() not working in Selenium Webdriver

driver.findElement(By.xpath("//label[text()='User Name:']/following::div/input")).sendKeys("UserName",Keys.TAB); By using a comma you can ...READ MORE

answered Feb 7 in Selenium by Priyaj
• 56,120 points
8,158 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,290 points
601 views
0 votes
1 answer

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

Download the executable driver from: ChromeDriver Download Before ...READ MORE

answered Mar 29, 2018 in Selenium by nsv999
• 5,030 points
126 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,030 points
77 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
449 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
57 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
4,544 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,030 points
1,237 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.