How To Use Desired Capabilities in Selenium WebDriver and Appium

How To Use Desired Capabilities in Selenium WebDriver and Appium

Desired Capabilities in Selenium and Appium are highly beneficial for automating web and mobile application testing. They allow developers and testers to set various test parameters, such as browser name, version, screen resolution, and more. It makes it easier to perform cross-browser testing and automate user interactions with web elements.

With the help of Desired Capabilities, developers can easily create robust automated tests that work across different platforms.

This article will help you understand what Desired Capabilities are, why it is used, and how developers and testers use them for automation testing.

What is Desired Capabilities?

The Desired Capabilities in Selenium help set the browser properties for automating web application testing. The capabilities are stored as key-value pairs encoded in a JSON object. The browser properties include the browser name, settings, version, and platform to customize the test environment.

Similar to Selenium, Desired Capabilities in Appium are highly helpful for automating mobile web application testing. It helps set browser properties for every test automation session. And these capabilities are sent as key-value pairs by Appium clients to the Appium server whenever a new automation session is requested.

In Selenium 4 and the latest versions, the desired capabilities class is deprecated. It is replaced with the Options class. You can use the Options class alone or combine the Desired Capabilities with Options.

Example of using Options Class in Selenium 4

Why do QA’s need Desired Capabilities?

Quality Assurance professionals use Desired Capabilities in Selenium to ensure that their automated tests are running properly. Desired Capabilities allow QA teams to customize the behavior of their automated tests, specify the browser type, set timeouts, and more.

This is especially important for web applications, as the browser and environment used can have a significant impact on the results of the test. By setting up desired capabilities, QA engineers can make sure that their tests are running in the exact environment they need them to be.

This helps them save time and resources while ensuring that their automated tests are running as expected. Furthermore, they can identify any potential issues or bugs in the application quickly and accurately.

Methods in Desired Capabilities for Selenium

The Desired Capabilities Class has various methods that allow QA to specify the required properties regarding the desired test environments. Now let’s look at all the methods available in the Desired Capabilities Class.

  • getCapability();

The getCapability() method helps retrieve the current system’s capabilities on which the tests are being executed.

public java.lang.Object getCapability(java.lang.String capabilityName)

  • setCapability();

The setCapability() method helps declare the test environments’ properties like device name, name of the operating system, operating system versions, browser name, and browser versions.

public java.lang.Object setCapability(java.lang.String capabilityName)

  • getBrowserName();

The getBrowserName() method helps retrieve the name of the browser of the current system.

public java.lang.String getBrowserName()

  • setBrowserName();

The setBrowserName() method helps set the browser name over which the tests will be performed.

public void setBrowserName(java.lang.String browserName)

  • getVersion();

The getVersion() method helps retrieve the browser or operating system version of the current system used for executing the tests.

public java.lang.String getVersion()

  • setVersion();

The setVersion() method helps define the browser version or the operating system for executing the tests.

public void setVersion(java.lang.String version)

  • getPlatform();

The getPlatform() method helps retrieve the platform details.

public Platform getPlatform()

  • setPlatform();

The setPlatform() method helps define the details of the platform.

public Platform setPlatform()

Code Snippet

The following code snippet explains how to use the setBrowserName and setPlatform methods,

Desired Capabilities in Selenium Testing for Various Browsers

So far, we have discussed the methods offered by the Desired Capabilities class. Now, let’s discuss how we can set different capabilities for various browsers like Chrome, Firefox, and Internet Explorer.

Desired Capabilities in Selenium WebDriver for the Chrome Browser

ChromeDriver is a standalone server used by the Selenium WebDriver to control the Chrome browser. Now we will discuss the desired capabilities the ChromeDriver supports and how to use them for the Chrome browser.

You can set the desired capabilities for ChromeDriver using these two methods,

  • ChromeOptions
  • Desired Capabilities

What is ChromeOptions?

ChromeOptions is a class that you can use in conjunction with the desired capabilities class in order to customize the different properties of the Chrome browser.

These are some of the common arguments from ChromeOptions class,

  • Disable-popup-blocking: It helps disable all the popups that appear on the Chrome browser.

  • Disable-infobars: It helps prevent Chrome from showing notifications such as “Chrome is being controlled by automated test software.

  • Make-default-browser: It helps set Chrome as the default browser.

  • Headless: It helps open the browser in headless mode.

  • Incognito: It opens Chrome in incognito mode

  • start-maximized: It helps opens the browser in maximized mode

Chrome Options for Adblocker

You can handle the Chrome extension using Desired Capabilities class and ChromeDriver Options. Follow the below steps to do so,

  1. You must install the AdBlocker extension on Chrome before using the Chrome Options class.

  2. Then extract the CRX File of the AdBlocker extension using any file extractor.

  3. Now, pass the file path of the downloaded CRX to the Chrome Options class.

  4. Instantiate the WebDriver using the capabilities and Chrome Option.

Code Snippet

The below code depicts the above steps for activating Adblocker

Desired Capabilities in Selenium WebDriver for the Firefox Browser

Similar to Chrome, you can also customize or manipulate the Desired Capabilities for Firefox.


This capability is specific to the Firefox browser, which helps control Firefox’s behavior. It is usually invoked as a member from alwaysMatch or firstMatch entries.

alwaysMatch: The capabilities mentioned inside this are the features required for the test session to start. The session will fail if the requirements don’t match.

firstMatch: It takes an array of capabilities as input. In this case, the session will start if at least one requirement matches.

moz:firefoxOptions can contain any of the below fields,

  • binary(String): This helps provide the path to the custom Firefox executable to use.

  • profile(String): You can use this to provide the path for the directory for the Firefox instance. You can use this to install custom certificates or Firefox extensions.

  • args(Array of Strings): This helps pass the command line arguments (CLA) to the Firefox binary.

  • log (String, Symbol): This helps show the log of the geckodriver

  • prefs (Hash): It helps assign the custom preference value

  • env (Env object) :It helps set the environment value

The following is an example of using Firefox capabilities with Desired Capabilities in Selenium WebDriver,

Desired Capabilities in Selenium WebDriver for the Internet Explorer Browser

Let us discuss the Desired Capabilities in Selenium WebDriver for Internet Explorer. To do this, we should use InternetExplorerOptions with Desired Capabilities in Selenium WebDriver.

InternetExplorerOptions is specific to Internet Explorer. This is an example of using desired capabilities in Selenium WebDriver for Internet Explorer.

Internet Explorer offers some specific capabilities to use.

  • ignoreZoomSettings(boolean): If set to true, this capability will stop checking if the browser’s zoom level is 100%. The default value is set to false.

public InternetExplorerOptions ignoreZoomSettings()

  • withInitialBrowserUrl(string): This capability helps set the initial URL of the website the browser should redirect to when it starts.

public InternetExplorerOptions withInitialBrowserUrl​(java.lang.String url)

  • destructivelyEnsureCleanSession(): This will help clear the browser cache.

public InternetExplorerOptions destructivelyEnsureCleanSession()

  • requireWindowFocus(boolean): It instructs the WebDriver to check if the browser window has proper focus before any keyboard or mouse event is performed.

public InternetExplorerOptions requireWindowFocus()

  • ignoreProtectedModeSettings(boolean): You can use this to skip checking if the browser is in protected mode while executing Selenium testing.

Desired Capabilities in Selenium Testing with Different Languages

You can use the Desired Capabilities in Selenium with different programming languages. You can use any of the languages supported by Selenium, like PHP, JavaScript, Java, C#, Python, and Ruby. This sample will explain how you can use the desired capabilities in Selenium using Java, Python, and C#.

Desired Capabilities in Selenium WebDriver for Java

Desired Capabilities in Selenium WebDriver for Python

Desired Capabilities in Selenium WebDriver for C#

In the above section, we have discussed the desired capabilities in Selenium testing using various browsers and languages.

Selenium testing can only check if your web application works perfectly on all desktop browsers. But it is vital to ensure your web applications or websites work well on mobile devices as well.

Businesses are going digital, and you need to make sure your web application or website is desktop and mobile-compatible. Nowadays, most people use their mobile phones to access web applications and websites. A recent report stated that there are more than 6.3 billion smartphone users worldwide. So, it is crucial to test if your applications work consistently across mobile browsers as well.

According to reports, over 59.16% of global website traffic comes via mobile devices, excluding tablet devices. This shows the number of people using their phones to access websites. So, businesses must create applications that are mobile-friendly to provide a great user experience for customers accessing websites or web applications via smartphones.


Though you can manually test if your applications are responsive and work perfectly across all mobile devices it is highly time-consuming and inefficient to use manual efforts. Thus, it is best to automate cross-browser testing for quick product delivery. But how to automate cross-browser testing across mobile browsers? Top open-source automation testing tools like Testsigma and Appium can help you automate mobile web testing.

Adding Desired Capabilities in Testsigma

Like web automation testing, you can easily automate mobile web testing of mobile web applications using Testsigma. Mobile web applications are applications that can run on a mobile device using a browser. To test if your product is compatible with all the devices, operating systems, and versions, you need to use a powerful automation tool like Testsigma that supports web, mobile, and API testing in one place. The Desired Capabilities in Testsigma allow you to customize the test environment while executing tests on the cloud.


In Testsigma, you can add or remove the capabilities to your test plan easily while executing tests. For example, if you need to add a capability, just add the key and the value in the respective fields. You can easily pick the right value type from the dropdown box before adding the value. Refer to the below image for reference.Here, when the acceptinsecureCerts method is set to true and added to the test, the browser will accept all the insecure and expired certificates.

Testsigma Desired Capabilities

Also, you can add multiple capabilities by adding them in separate columns. It is as simple as that, you don’t have to write any complex code. In the below image, two different capabilities are added – acceptinsecureCerts and goog:chromeOptions. I have used the goog:chromeOptions to add a chrome extension. You can also add multiple extensions by separating the values with a comma.

Testsigma Desired Capabilities

Now, if you want to delete any capability, just use the remove button, and it will be deleted.

Testsigma Desired Capabilities

To perform browser testing of mobile web apps, Testsigma is the one-stop solution for ensuring compatibility across all the latest browsers, devices, and operating systems. Testsigma is available as open source and free. It is also a no-code test automation tool that lets you automate reliable tests for your web, mobile and APIs without learning to code.

Desired Capabilities in Appium for Mobile Test Automation

Similar to the capabilities in Selenium, Appium’s desired capabilities help instruct the Appium server about the desired test environments for testing applications. Using Appium, you can check if your web application is compatible with mobile browsers. Now, we will discuss how to use Desired Capabilities in Appium.

Example of Desired Capabilities in Appium Testing

As a new test automation session starts, the Appium client will send a request to the Appium server using the Desired Capabilities as key-value pairs.

With these desired capabilities, you can instruct the Appium drivers on how the mobile test automation test has to work. Here is an example of using desired capabilities in Appium,

In the above sample, we instruct the drivers to start the mobile automation test on iPhone 14 for the application in the specified file location.

Appium supports different capabilities. Some are specific to the platform or driver, whereas some are common for every platform or driver. Here is a list of the standard or general desired capabilities in Appium.

Standard Desired Capabilities in Appium Testing

These are some of the general or standard desired capabilities in Appium testing.

  • automationName: You can use this to specify which automation engine to use. For example, Espresso, Appium for Android, and XCUITest for iOS. But, by default, Appium is used.

  • deviceName: Type of mobile device to use. For example, in the above example, iPhone 14 is used.

  • platformName: Instruct the driver about the mobile platform to use

  • platformVersion: Mention the mobile platform version to use.

  • app: This helps provide the path of the application you need to test. It could be an absolute path or a remote path with HTTP URL.

  • newCommandTimeout: The waiting time for a new command from the client

  • browserName: Set the browser name for the automation test. For example, Chrome for Android or Safari for iOS.

  • language: You can use this to set the language of Android, Windows, or iOS.

Some of the other general capabilities include eventTimings, noReset, fullReset, and more.

Desired Capabilities in Appium for Android

  • appActivity: This capability represents the application activity that you want to launch from the package.

  • appPackage: This capability represents the package of the Android application that you want to run.

  • appWaitActivity: You can use this to provide the Android activity you need to wait for.

  • appWaitPackage: You can use this to provide the Java package of the app you need to wait for.

  • appWaitDuration: You can use this to set the wait time for the appWaitActivity to start. By default, it is 20000 milliseconds.

  • deviceReadyTimeout: This helps instruct the driver about the timeout when it waits for the device to be ready.

There are a few more Android capabilities, including remoteAdbHost, androidInstallPath, adbPort, systemPort, and more.

Desired Capabilities in Appium for iOS

  • autoAcceptAlerts: Accept all the popups and alerts on iOS devices.

  • autoDismissAlerts: Dismiss all the popups and alerts

  • safariInitialUrl: Provide the initial URL to open when Safari is launched.

  • appName: Display the name of the application under test.

There are other iOS capabilities like customSSLCert, safariAllowPopups, and more.

Appium Vs. Testsigma for Mobile Test Automation

Both Appium and Testsigma are beneficial for automating mobile web testing of applications. Yet, there are major differences between Appium and Testsigma. Let’s look at the Appium vs. Testsigma comparison to learn more.

  • To use Appium, you must install various prerequisite tools such as JDK, Android SDK, Eclipse, NodeJs, Appium Client library, Selenium Server JAR, Appium for Desktop, and more.

  • Using Appium can be difficult for users with no technical knowledge to create test cases.

  • It offers only limited support to hybrid apps.

On the other hand, Testsigma is an AI-powered cloud automation test platform that offers the following benefits,

  • You don’t need to download any software or additional files. You can simply access the tool via the cloud by signing up for the Testsigma Cloud.

  • Using Testsigma, you can easily create test cases in simple English using the NLPs offered by the tool. It makes your automation testing 5x faster.

  • It is a scriptless automation testing tool which means you don’t have to write complex code. Anyone in your team can access the tool, as not much technical knowledge is required.

  • 24×7 dedicated customer support for premium users.

Desired Capabilities in Testsigma are very easy and simple to use. You can simply add the necessary capabilities to your test plan using the Desired Capabilities field provided in the tool. Sign up for the 21-day free trial to know more about how it helps automate your mobile web testing.


I hope you might now have an idea of how Desired Capabilities are an important part of automated testing. They provide a way to configure the browser session, set up the environment, and control how you want to execute the test. These capabilities allow testers to specify the exact browser version they want to use and other features like proxy settings, timeouts, and language preferences.

With Desired Capabilities, QA teams can also run tests on different browsers and operating systems without having to rewrite code.

Frequently Asked Questions

How to set Desired Capabilities in Selenium 4?

In Selenium 4, you have to use the Options class instead of Desired Capabilities. It provides methods to change the browser properties like cookies, disable popups, incognito, headless, add extensions, and more. For example, ChromeDriver Capabilities are replaced by ChromeOptions.

ChromeOptions options = new ChromeOptions();

What can I use instead of Desired Capabilities in Selenium?

You can use Options instead of using Desired Capabilities in Selenium. You can either use only the Options class or use Desired Capabilities with Options.

What is the use of Desired Capabilities Class?

The Desired Capabilities class helps you set the browser properties such as browser name, version, the path to the browser driver, and more to perform automated browser testing.

Test automation made easy

Start your smart continuous testing journey today with Testsigma.



How to write test cases for Amazon shopping cart
How to write test cases for Amazon shopping cart?
WPF Automation Testing What, Why, Best Practices & Tools
WPF Automation Testing: What, Why, Best Practices & Tools
Progressive Web Apps (PWA) Testing What , How to do & Tools
Progressive Web Apps (PWA) Testing | What , How to do & Tools