HtmlElement.Net
Public Member Functions | Protected Member Functions | Properties | List of all members
HtmlElements.WebDriverWrapper Class Reference

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.

Public Member Functions

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...
 

Protected Member Functions

 WebDriverWrapper (ISearchContext webDriverOrWrapper)
 Initializes wrapper converting provided object to WebDriver More...
 

Properties

IPageObjectFactory PageObjectFactory [get]
 Gets the page object factory used to initialize current page object instance. More...
 
IWebDriver WrappedDriver [get]
 Gets the T:OpenQA.Selenium.IWebDriver wrapped by current page object instance. More...
 

Detailed Description

Represents object wrapping web driver. Provides methods for executing JavaScript and retrieving wrapped driver instance.

Constructor & Destructor Documentation

◆ WebDriverWrapper()

HtmlElements.WebDriverWrapper.WebDriverWrapper ( ISearchContext  webDriverOrWrapper)
protected

Initializes wrapper converting provided object to WebDriver

Parameters
webDriverOrWrapperIWebDriver, IWebElement or anything else which is wrapping WebDriver instance and can be used for locating elements

Member Function Documentation

◆ ExecuteAsyncScript()

object HtmlElements.WebDriverWrapper.ExecuteAsyncScript ( string  script,
params object[]  args 
)

Executes JavaScript asynchronously in the context of the currently selected frame or window.

Parameters
scriptThe JavaScript code to execute.
argsThe arguments to the script.
Returns
The value returned by the script.
Exceptions
InvalidOperationExceptionThrown 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
scriptThe JavaScript code to execute.
argsThe arguments to the script.
Returns
The value returned by the script.
Exceptions
InvalidOperationExceptionThrown 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
byThe locating mechanism to use.
Returns
The first matching T:OpenQA.Selenium.IWebElement on the current context.

◆ FindElement< TElement >()

TElement HtmlElements.WebDriverWrapper.FindElement< TElement > ( By @  by)

Finds the first IWebElement using given method and creates a page object of given type wrapping the element.

Template Parameters
TElementThe type of the element.
Parameters
byThe locating mechanism to use.
Returns
The first matching IWebElement on the current context wrapped by page object instance of given type.
Type Constraints
TElement :class 

◆ FindElements()

ReadOnlyCollection<IWebElement> HtmlElements.WebDriverWrapper.FindElements ( By @  by)

Finds all IWebElements within the current context using the given mechanism.

Parameters
byThe 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 >()

IList<TElement> HtmlElements.WebDriverWrapper.FindElements< TElement > ( By @  by)

Finds all IWebElements within the current context using the given mechanism and creates page objects wrapping it.

Parameters
byThe 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.
Type Constraints
TElement :class 

◆ ToString()

override string HtmlElements.WebDriverWrapper.ToString ( )

Describes actual page object type and wrapped search context.

Property Documentation

◆ PageObjectFactory

IPageObjectFactory HtmlElements.WebDriverWrapper.PageObjectFactory
getprotected

Gets the page object factory used to initialize current page object instance.

Exceptions
InvalidOperationExceptionThrown 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
InvalidOperationExceptionThrown when wrapped search context cannot be converted to IWebDriver.