Details about Desired Capabilities in Selenium

"All about ""Desired Capabilities in Selenium "

When we start talking about desired capabilities in Selenium, the first question that arises in your mind will be what is desired capability. As you know, different test scenarios should be conducted in different environments such as web browser, mobile device, mobile simulator, mobile emulator etc. Desired capabilities class tells the webdriver about the environment that is being used or executing a test scenario.

What is Desired Capability

Desired capability is a series of value or key pairs that stores the web browser properties such as browser name, browser version, the path of the browser in the system etc which will help to determine the behavior of the browser at run time. Further, desired capability can be used for configuring the web driver instance of selenium webdriver and it is more used in mobile application automation and Selenium grid.

Different Types of Desired Capabilities Methods

There are different types of desired capabilities methods and some of them are as follows.

  • getBrowserName()
  • setBrowserName()
  • getVersion()
  • setVersion()
  • getPlatform()
  • setPlatform()
  • getCapability Method
  • setCapabilityMethod

Example for Setcapability Method

Here is an example or setcapability Method where the testcase will run on Internet Explorer browser using selenium web driver.

The code will be as follows

importorg.openqa.selenium.WebDriver;
importorg.openqa.selenium.ie.InternetExplorerDriver;

public class IEtestforDesiredCapabilities {
 
public static void main(String[] args) {
 
WebDriver IEdriver = new InternetExplorerDriver();
driver.manage().window().maximize();
driver.get(“http://gmail.com”);
 
driver.quit();
}
 
}

Now the code can be run from eclipse and the console can be checked.

The following error is shown when this code is executed and the reason for the error is that the path to internet explorer browser was not set. The solution for the error is also provided in the warning session.

The path to the driver executable must be set by the webdriver.ie.driver system property; for more information, see http://code.google.com/p/selenium/wiki/InternetExplorerDriver. The latest version can be downloaded from http://code.google.com/p/selenium/downloads/list

Dec 11, 201212:59:43 PM org.openqa.selenium.ie.InternetExplorerDriver Server initialize Lib

WARNING: This method of starting the IE driver is deprecated and will be removed in selenium 2.26. Please download the IEDriverServer.exe from http://code.google.com/p/selenium/downloads/list and ensure that it is in your PATH.

Several examples can be given for each type of desired capability and the same will be taught in detail in all selenium training programs. One should have in-depth knowledge of desired capabilities in selenium to master selenium technology and hence the same will be taught thoroughly in all selenium tutorials.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>