How can DesiredCapabilities be utilized to customize the behaviour of the browser driver?

How can DesiredCapabilities be utilized to customize the behavior of the browser driver, such as setting timeouts or enabling/disabling features?

Hey Saanvi,

DesiredCapabilities in Selenium WebDriver are key/value pairs that configure browser behavior. They enable users to customize WebDriver instances, such as setting the FirefoxDriver path for non-default installations. Detailed documentation is available for DesiredCapabilities and specific drivers like ChromeDriver.

Hey Saanvi,

Here you must remember some pointers , below i am sharing you the example along with the pointers to consider when adding desired capabilities.

  • It is a class in org.openqa.selenium.remote.DesiredCapabilities package

  • It gives the facility to set the properties of the browser. Such as to set BrowserName, Platform, and Version of Browser.

  • Mostly, the DesiredCapabilities class is used when we use Selenium Grid.

  • We have to execute mutiple TestCases on multiple Systems with different browser with Different version and Different Operating System.


WebDriver driver;
String baseUrl , nodeUrl;
baseUrl = "";
nodeUrl = "";

DesiredCapabilities capability = DesiredCapabilities.firefox();

driver = new RemoteWebDriver(new URL(nodeUrl),capability);
driver.manage().timeouts().implicitlyWait(2, TimeUnit.MINUTES);

I hope you understood the concept.