Represents object wrapping web driver. Provides methods for executing JavaScript and retrieving wrapped driver instance.
More...
Inherits ISearchContext, IWrapsDriver, and IJavaScriptExecutor.
Inherited by HtmlElements.Elements.HtmlElement, and HtmlElements.Elements.HtmlPage.
|
object | ExecuteScript (string script, params object[] args) |
| Executes JavaScript in the context of the currently selected frame or window. More...
|
|
object | ExecuteAsyncScript (string script, params object[] args) |
| Executes JavaScript asynchronously in the context of the currently selected frame or window. More...
|
|
ReadOnlyCollection< IWebElement > | FindElements (By @by) |
| Finds all IWebElements within the current context using the given mechanism. More...
|
|
IWebElement | FindElement (By @by) |
| Finds the first T:OpenQA.Selenium.IWebElement using the given method. More...
|
|
TElement | FindElement< TElement > (By @by) |
| Finds the first IWebElement using given method and creates a page object of given type wrapping the element. More...
|
|
IList< TElement > | FindElements< TElement > (By @by) |
| Finds all IWebElements within the current context using the given mechanism and creates page objects wrapping it. More...
|
|
override string | ToString () |
| Describes actual page object type and wrapped search context. More...
|
|
|
| WebDriverWrapper (ISearchContext webDriverOrWrapper) |
| Initializes wrapper converting provided object to WebDriver More...
|
|
Represents object wrapping web driver. Provides methods for executing JavaScript and retrieving wrapped driver instance.
◆ WebDriverWrapper()
HtmlElements.WebDriverWrapper.WebDriverWrapper |
( |
ISearchContext |
webDriverOrWrapper | ) |
|
|
protected |
Initializes wrapper converting provided object to WebDriver
- Parameters
-
webDriverOrWrapper | IWebDriver, IWebElement or anything else which is wrapping WebDriver instance and can be used for locating elements |
◆ ExecuteAsyncScript()
object HtmlElements.WebDriverWrapper.ExecuteAsyncScript |
( |
string |
script, |
|
|
params object[] |
args |
|
) |
| |
Executes JavaScript asynchronously in the context of the currently selected frame or window.
- Parameters
-
script | The JavaScript code to execute. |
args | The arguments to the script. |
- Returns
- The value returned by the script.
- Exceptions
-
InvalidOperationException | Thrown when wrapped IWebDriver cannot be converted to IJavaScriptExecutor. |
◆ ExecuteScript()
object HtmlElements.WebDriverWrapper.ExecuteScript |
( |
string |
script, |
|
|
params object[] |
args |
|
) |
| |
Executes JavaScript in the context of the currently selected frame or window.
- Parameters
-
script | The JavaScript code to execute. |
args | The arguments to the script. |
- Returns
- The value returned by the script.
- Exceptions
-
InvalidOperationException | Thrown when wrapped IWebDriver cannot be converted to IJavaScriptExecutor. |
The method executes JavaScript in the context of the currently selected frame or window. This means that "document" will refer to the current document. If the script has a return value, then the following steps will be taken:
-
For an HTML element, this method returns a T:OpenQA.Selenium.IWebElement
-
For a number, a T:System.Int64 is returned
-
For a boolean, a T:System.Boolean is returned
-
For all other cases a T:System.String is returned.
-
For an array, we check the first element, and attempt to return a T:System.Collections.Generic.List`1 of that type, following the rules above. Nested lists are not supported.
-
If the value is null or there is no return value,
null
is returned.
Arguments must be a number (which will be converted to a T:System.Int64), a T:System.Boolean, a T:System.String or a T:OpenQA.Selenium.IWebElement. An exception will be thrown if the arguments do not meet these criteria. The arguments will be made available to the JavaScript via the "arguments" magic variable, as if the function were called via "Function.apply"
◆ FindElement()
IWebElement HtmlElements.WebDriverWrapper.FindElement |
( |
By @ |
by | ) |
|
Finds the first T:OpenQA.Selenium.IWebElement using the given method.
- Parameters
-
by | The locating mechanism to use. |
- Returns
- The first matching T:OpenQA.Selenium.IWebElement on the current context.
◆ FindElement< TElement >()
Finds the first IWebElement using given method and creates a page object of given type wrapping the element.
- Template Parameters
-
TElement | The type of the element. |
- Parameters
-
by | The locating mechanism to use. |
- Returns
- The first matching IWebElement on the current context wrapped by page object instance of given type.
◆ FindElements()
ReadOnlyCollection<IWebElement> HtmlElements.WebDriverWrapper.FindElements |
( |
By @ |
by | ) |
|
Finds all IWebElements within the current context using the given mechanism.
- Parameters
-
by | The locating mechanism to use. |
- Returns
- A T:System.Collections.ObjectModel.ReadOnlyCollection`1 of all WebElements matching the current criteria, or an empty list if nothing matches.
◆ FindElements< TElement >()
Finds all IWebElements within the current context using the given mechanism and creates page objects wrapping it.
- Parameters
-
by | The locating mechanism to use. |
- Returns
- A IList<T> of all WebElements matching the current criteria wrapped by page objects instances of given type, or an empty list if nothing matches.
◆ ToString()
override string HtmlElements.WebDriverWrapper.ToString |
( |
| ) |
|
Describes actual page object type and wrapped search context.
◆ PageObjectFactory
Gets the page object factory used to initialize current page object instance.
- Exceptions
-
InvalidOperationException | Thrown if page factory was not set during page object initialization. |
◆ WrappedDriver
IWebDriver HtmlElements.WebDriverWrapper.WrappedDriver |
|
get |
Gets the T:OpenQA.Selenium.IWebDriver wrapped by current page object instance.
- Exceptions
-
InvalidOperationException | Thrown when wrapped search context cannot be converted to IWebDriver. |