Class WebDriverExtensions
Extension methods for OpenQA.Selenium.IWebDriver.
public static class WebDriverExtensions
- Inheritance
-
WebDriverExtensions
- Inherited Members
Methods
GetBrowserId(IWebDriver)
Gets the BrowserId from a WebDriver, if the browser identification functionality is activated.
public static BrowserId GetBrowserId(this IWebDriver webDriver)
Parameters
webDriver
IWebDriver
Returns
Remarks
If the WebDriver is not a proxy which was created via IGetsProxyWebDriver, or if both AddIdentification & AddQuirks were false when the proxy was created then this method will return null. Otherwise, this method will get the browser identification information from the proxy.
This is a convenience method which avoids the need to manually type-check for the IHasBrowserId interface.
GetFirstApplicableQuirk(IWebDriver, params string[])
Gets the first of an ordered collection of quirks which affects the specified WebDriver.
public static string GetFirstApplicableQuirk(this IWebDriver webDriver, params string[] orderedQuirks)
Parameters
webDriver
IWebDriverA WebDriver
orderedQuirks
string[]The an ordered collection of quirk names
Returns
- string
The first item from
orderedQuirks
which is applicable to the WebDriver, or a null reference if none of the specified quirks are applicable.
Remarks
If the WebDriver is not a proxy which was created via IGetsProxyWebDriver, or if
AddQuirks was false when the proxy was created
then this method will always return null.
Otherwise, if the WebDriver is affected by any of the specified quirks then this method will return
the string quirk-name of the first of the orderedQuirks
which is applicable to the
WebDriver. It will return null if none of the specified quirks are applicable to
the WebDriver.
For more information on what quirks are, see the documentation for IHasQuirks.
GetQuirks(IWebDriver)
Gets a collection of string quirk-names which affect the specified WebDriver, if the browser quirks functionality is activated.
public static IReadOnlyCollection<string> GetQuirks(this IWebDriver webDriver)
Parameters
webDriver
IWebDriver
Returns
- IReadOnlyCollection<string>
The browser quirks, or an empty collection.
Remarks
If the WebDriver is not a proxy which was created via IGetsProxyWebDriver, or if AddQuirks was false when the proxy was created then this method will return an empty collection. Otherwise, this method will get the collection of named quirks which affect the current WebDriver.
This is a convenience method which avoids the need to manually type-check for the IHasQuirks interface.
For more information on browser quirks and their purpose, please read the remarks for IHasQuirks.
HasQuirk(IWebDriver, string)
Gets a value indicating whether or not the current object is affected by the specified named quirk.
public static bool HasQuirk(this IWebDriver webDriver, string quirkName)
Parameters
webDriver
IWebDriverA WebDriver
quirkName
stringThe name of a quirk
Returns
Remarks
If the WebDriver is not a proxy which was created via IGetsProxyWebDriver, or if AddQuirks was false when the proxy was created then this method will always return false. Otherwise, this method will return true only if the specified WebDriver is affected by the specified quirk.
For more information on what quirks are, see the documentation for IHasQuirks.
Unproxy(IWebDriver)
'Unproxies' a WebDriver which may or may not be a proxy.
public static IWebDriver Unproxy(this IWebDriver webDriver)
Parameters
webDriver
IWebDriverA WebDriver which may or may not be a proxy.
Returns
- IWebDriver
An 'unproxied' WebDriver
Remarks
If the webDriver
is a proxy then this method returns the original 'unproxied' driver.
If the WebDriver is not a proxy then this method returns the webDriver
directly.
This way, whether the input parameter was a proxy or not, the output is an unproxied WebDriver.
For more information about this library's proxying functionality, see IGetsProxyWebDriver.
- See Also