C# Class OpenQA.Selenium.Support.Events.EventFiringWebDriver

A wrapper around an arbitrary WebDriver instance which supports registering for events, e.g. for logging purposes.
Inheritance: IWebDriver, IJavaScriptExecutor, ITakesScreenshot, IWrapsDriver
Mostra file Open project: asynchrony/Selenium2 Class Usage Examples

Public Methods

Method Description
Close ( ) : void

Close the current window, quitting the browser if it is the last window currently open.

Dispose ( ) : void

Frees all managed and unmanaged resources used by this instance.

EventFiringWebDriver ( IWebDriver parentDriver ) : System

Initializes a new instance of the EventFiringWebDriver class.

ExecuteAsyncScript ( string script ) : object

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

ExecuteScript ( string script ) : object

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

The ExecuteScriptmethod 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 IWebElement For a number, a System.Int64 is returned For a boolean, a System.Boolean is returned For all other cases a System.String is returned. For an array,we check the first element, and attempt to return a List{T} of that type, following the rules above. Nested lists are not supported. If the value is null or there is no return value, is returned.

Arguments must be a number (which will be converted to a System.Int64), a System.Boolean, a System.String or a 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 ( By by ) : IWebElement

Find the first IWebElement using the given method.

FindElements ( By by ) : ReadOnlyCollection

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

GetScreenshot ( ) : Screenshot

Gets a Screenshot object representing the image of the page on the screen.

Manage ( ) : IOptions

Instructs the driver to change its settings.

Navigate ( ) : INavigation

Instructs the driver to navigate the browser to another location.

Quit ( ) : void

Quits this driver, closing every associated window.

SwitchTo ( ) : ITargetLocator

Instructs the driver to send future commands to a different frame or window.

Protected Methods

Method Description
Dispose ( bool disposing ) : void

Frees all managed and, optionally, unmanaged resources used by this instance.

OnElementClicked ( OpenQA.Selenium.Support.Events.WebElementEventArgs e ) : void

Raises the ElementClicked event.

OnElementClicking ( OpenQA.Selenium.Support.Events.WebElementEventArgs e ) : void

Raises the ElementClicking event.

OnElementValueChanged ( OpenQA.Selenium.Support.Events.WebElementEventArgs e ) : void

Raises the ElementValueChanged event.

OnElementValueChanging ( OpenQA.Selenium.Support.Events.WebElementEventArgs e ) : void

Raises the ElementValueChanging event.

OnException ( OpenQA.Selenium.Support.Events.WebDriverExceptionEventArgs e ) : void

Raises the ExceptionThrown event.

OnFindElementCompleted ( OpenQA.Selenium.Support.Events.FindElementEventArgs e ) : void

Raises the FindElementCompleted event.

OnFindingElement ( OpenQA.Selenium.Support.Events.FindElementEventArgs e ) : void

Raises the FindingElement event.

OnNavigated ( WebDriverNavigationEventArgs e ) : void

Raises the Navigated event.

OnNavigatedBack ( WebDriverNavigationEventArgs e ) : void

Raises the NavigatedBack event.

OnNavigatedForward ( WebDriverNavigationEventArgs e ) : void

Raises the NavigatedForward event.

OnNavigating ( WebDriverNavigationEventArgs e ) : void

Raises the Navigating event.

OnNavigatingBack ( WebDriverNavigationEventArgs e ) : void

Raises the NavigatingBack event.

OnNavigatingForward ( WebDriverNavigationEventArgs e ) : void

Raises the NavigatingForward event.

OnScriptExecuted ( OpenQA.Selenium.Support.Events.WebDriverScriptEventArgs e ) : void

Raises the ScriptExecuted event.

OnScriptExecuting ( OpenQA.Selenium.Support.Events.WebDriverScriptEventArgs e ) : void

Raises the ScriptExecuting event.

Private Methods

Method Description
UnwrapElementArguments ( object args ) : object[]
WrapElement ( IWebElement underlyingElement ) : IWebElement

Method Details

Close() public method

Close the current window, quitting the browser if it is the last window currently open.
public Close ( ) : void
return void

Dispose() public method

Frees all managed and unmanaged resources used by this instance.
public Dispose ( ) : void
return void

Dispose() protected method

Frees all managed and, optionally, unmanaged resources used by this instance.
protected Dispose ( bool disposing ) : void
disposing bool to dispose of only managed resources; /// to dispose of managed and unmanaged resources.
return void

EventFiringWebDriver() public method

Initializes a new instance of the EventFiringWebDriver class.
public EventFiringWebDriver ( IWebDriver parentDriver ) : System
parentDriver IWebDriver The driver to register events for.
return System

ExecuteAsyncScript() public method

Executes JavaScript asynchronously in the context of the currently selected frame or window.
public ExecuteAsyncScript ( string script ) : object
script string The JavaScript code to execute.
return object

ExecuteScript() public method

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

The ExecuteScriptmethod 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 IWebElement For a number, a System.Int64 is returned For a boolean, a System.Boolean is returned For all other cases a System.String is returned. For an array,we check the first element, and attempt to return a List{T} of that type, following the rules above. Nested lists are not supported. If the value is null or there is no return value, is returned.

Arguments must be a number (which will be converted to a System.Int64), a System.Boolean, a System.String or a 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"

public ExecuteScript ( string script ) : object
script string The JavaScript code to execute.
return object

FindElement() public method

Find the first IWebElement using the given method.
If no element matches the criteria.
public FindElement ( By by ) : IWebElement
by By The locating mechanism to use.
return IWebElement

FindElements() public method

Find all IWebElements within the current context using the given mechanism.
public FindElements ( By by ) : ReadOnlyCollection
by By The locating mechanism to use.
return ReadOnlyCollection

GetScreenshot() public method

Gets a Screenshot object representing the image of the page on the screen.
public GetScreenshot ( ) : Screenshot
return Screenshot

Manage() public method

Instructs the driver to change its settings.
public Manage ( ) : IOptions
return IOptions

Navigate() public method

Instructs the driver to navigate the browser to another location.
public Navigate ( ) : INavigation
return INavigation

OnElementClicked() protected method

Raises the ElementClicked event.
protected OnElementClicked ( OpenQA.Selenium.Support.Events.WebElementEventArgs e ) : void
e OpenQA.Selenium.Support.Events.WebElementEventArgs A that contains the event data.
return void

OnElementClicking() protected method

Raises the ElementClicking event.
protected OnElementClicking ( OpenQA.Selenium.Support.Events.WebElementEventArgs e ) : void
e OpenQA.Selenium.Support.Events.WebElementEventArgs A that contains the event data.
return void

OnElementValueChanged() protected method

Raises the ElementValueChanged event.
protected OnElementValueChanged ( OpenQA.Selenium.Support.Events.WebElementEventArgs e ) : void
e OpenQA.Selenium.Support.Events.WebElementEventArgs A that contains the event data.
return void

OnElementValueChanging() protected method

Raises the ElementValueChanging event.
protected OnElementValueChanging ( OpenQA.Selenium.Support.Events.WebElementEventArgs e ) : void
e OpenQA.Selenium.Support.Events.WebElementEventArgs A that contains the event data.
return void

OnException() protected method

Raises the ExceptionThrown event.
protected OnException ( OpenQA.Selenium.Support.Events.WebDriverExceptionEventArgs e ) : void
e OpenQA.Selenium.Support.Events.WebDriverExceptionEventArgs A that contains the event data.
return void

OnFindElementCompleted() protected method

Raises the FindElementCompleted event.
protected OnFindElementCompleted ( OpenQA.Selenium.Support.Events.FindElementEventArgs e ) : void
e OpenQA.Selenium.Support.Events.FindElementEventArgs A that contains the event data.
return void

OnFindingElement() protected method

Raises the FindingElement event.
protected OnFindingElement ( OpenQA.Selenium.Support.Events.FindElementEventArgs e ) : void
e OpenQA.Selenium.Support.Events.FindElementEventArgs A that contains the event data.
return void

OnNavigated() protected method

Raises the Navigated event.
protected OnNavigated ( WebDriverNavigationEventArgs e ) : void
e WebDriverNavigationEventArgs A that contains the event data.
return void

OnNavigatedBack() protected method

Raises the NavigatedBack event.
protected OnNavigatedBack ( WebDriverNavigationEventArgs e ) : void
e WebDriverNavigationEventArgs A that contains the event data.
return void

OnNavigatedForward() protected method

Raises the NavigatedForward event.
protected OnNavigatedForward ( WebDriverNavigationEventArgs e ) : void
e WebDriverNavigationEventArgs A that contains the event data.
return void

OnNavigating() protected method

Raises the Navigating event.
protected OnNavigating ( WebDriverNavigationEventArgs e ) : void
e WebDriverNavigationEventArgs A that contains the event data.
return void

OnNavigatingBack() protected method

Raises the NavigatingBack event.
protected OnNavigatingBack ( WebDriverNavigationEventArgs e ) : void
e WebDriverNavigationEventArgs A that contains the event data.
return void

OnNavigatingForward() protected method

Raises the NavigatingForward event.
protected OnNavigatingForward ( WebDriverNavigationEventArgs e ) : void
e WebDriverNavigationEventArgs A that contains the event data.
return void

OnScriptExecuted() protected method

Raises the ScriptExecuted event.
protected OnScriptExecuted ( OpenQA.Selenium.Support.Events.WebDriverScriptEventArgs e ) : void
e OpenQA.Selenium.Support.Events.WebDriverScriptEventArgs A that contains the event data.
return void

OnScriptExecuting() protected method

Raises the ScriptExecuting event.
protected OnScriptExecuting ( OpenQA.Selenium.Support.Events.WebDriverScriptEventArgs e ) : void
e OpenQA.Selenium.Support.Events.WebDriverScriptEventArgs A that contains the event data.
return void

Quit() public method

Quits this driver, closing every associated window.
public Quit ( ) : void
return void

SwitchTo() public method

Instructs the driver to send future commands to a different frame or window.
public SwitchTo ( ) : ITargetLocator
return ITargetLocator