Table of Contents

Class DesiredCapabilities

Namespace
OpenQA.Selenium.Remote
Assembly
WebDriver.dll

Class to Create the capabilities of the browser you require for IWebDriver. If you wish to use default values use the static methods

public class DesiredCapabilities : ICapabilities
Inheritance
DesiredCapabilities
Implements
Inherited Members

Constructors

DesiredCapabilities()

Initializes a new instance of the DesiredCapabilities class

public DesiredCapabilities()

DesiredCapabilities(Dictionary<string, object>)

Initializes a new instance of the DesiredCapabilities class

public DesiredCapabilities(Dictionary<string, object> rawMap)

Parameters

rawMap Dictionary<string, object>

Dictionary of items for the remote driver

Examples

DesiredCapabilities capabilities = new DesiredCapabilities(new Dictionary<string,object>(){["browserName","firefox"],["version",string.Empty],["javaScript",true]});

DesiredCapabilities(string, string, Platform)

Initializes a new instance of the DesiredCapabilities class

public DesiredCapabilities(string browser, string version, Platform platform)

Parameters

browser string

Name of the browser e.g. firefox, internet explorer, safari

version string

Version of the browser

platform Platform

The platform it works on

Properties

BrowserName

Gets the browser name

public string BrowserName { get; }

Property Value

string

IsJavaScriptEnabled

Gets or sets a value indicating whether the browser is JavaScript enabled

public bool IsJavaScriptEnabled { get; set; }

Property Value

bool

Platform

Gets or sets the platform

public Platform Platform { get; set; }

Property Value

Platform

Version

Gets the browser version

public string Version { get; }

Property Value

string

Methods

Android()

Method to return a new DesiredCapabilities using defaults

public static DesiredCapabilities Android()

Returns

DesiredCapabilities

New instance of DesiredCapabilities for use with Android

Chrome()

Method to return a new DesiredCapabilities using defaults

public static DesiredCapabilities Chrome()

Returns

DesiredCapabilities

New instance of DesiredCapabilities for use with Chrome

Edge()

Method to return a new DesiredCapabilities using defaults

public static DesiredCapabilities Edge()

Returns

DesiredCapabilities

New instance of DesiredCapabilities for use with Microsoft Edge

Equals(object)

Compare two DesiredCapabilities and will return either true or false

public override bool Equals(object obj)

Parameters

obj object

DesiredCapabilities you wish to compare

Returns

bool

true if they are the same or false if they are not

Firefox()

Method to return a new DesiredCapabilities using defaults

public static DesiredCapabilities Firefox()

Returns

DesiredCapabilities

New instance of DesiredCapabilities for use with Firefox

GetCapability(string)

Gets a capability of the browser.

public object GetCapability(string capability)

Parameters

capability string

The capability to get.

Returns

object

An object associated with the capability, or null if the capability is not set on the browser.

GetHashCode()

Return HashCode for the DesiredCapabilities that has been created

public override int GetHashCode()

Returns

int

Integer of HashCode generated

HasCapability(string)

Gets a value indicating whether the browser has a given capability.

public bool HasCapability(string capability)

Parameters

capability string

The capability to get.

Returns

bool

Returns true if the browser has the capability; otherwise, false.

HtmlUnit()

Method to return a new DesiredCapabilities using defaults

public static DesiredCapabilities HtmlUnit()

Returns

DesiredCapabilities

New instance of DesiredCapabilities for use with HTMLUnit

HtmlUnitWithJavaScript()

Method to return a new DesiredCapabilities using defaults

public static DesiredCapabilities HtmlUnitWithJavaScript()

Returns

DesiredCapabilities

New instance of DesiredCapabilities for use with HTMLUnit with JS

IPad()

Method to return a new DesiredCapabilities using defaults

public static DesiredCapabilities IPad()

Returns

DesiredCapabilities

New instance of DesiredCapabilities for use with iPad

IPhone()

Method to return a new DesiredCapabilities using defaults

public static DesiredCapabilities IPhone()

Returns

DesiredCapabilities

New instance of DesiredCapabilities for use with iPhone

InternetExplorer()

Method to return a new DesiredCapabilities using defaults

public static DesiredCapabilities InternetExplorer()

Returns

DesiredCapabilities

New instance of DesiredCapabilities for use with Internet Explorer

Opera()

Method to return a new DesiredCapabilities using defaults

public static DesiredCapabilities Opera()

Returns

DesiredCapabilities

New instance of DesiredCapabilities for use with Opera

PhantomJS()

Method to return a new DesiredCapabilities using defaults

public static DesiredCapabilities PhantomJS()

Returns

DesiredCapabilities

New instance of DesiredCapabilities for use with Firefox

Safari()

Method to return a new DesiredCapabilities using defaults

public static DesiredCapabilities Safari()

Returns

DesiredCapabilities

New instance of DesiredCapabilities for use with Safari

SetCapability(string, object)

Sets a capability of the browser.

public void SetCapability(string capability, object capabilityValue)

Parameters

capability string

The capability to get.

capabilityValue object

The value for the capability.

ToDictionary()

Converts the ICapabilities object to a Dictionary<TKey, TValue>.

public Dictionary<string, object> ToDictionary()

Returns

Dictionary<string, object>

The Dictionary<TKey, TValue> containing the capabilities.

ToString()

Return a string of capabilities being used

public override string ToString()

Returns

string

String of capabilities being used