WebDriver¶
This is a JavaScript wrapper for RemoteWebDriver of Selenium .NET library.
Action Summary¶
Action | Description |
---|---|
Actions | Gets Actions object. |
AlertIsPresent | Checks if alert is displayed. |
Cleanup | Cleans up folders created by temporary Chrome profiles in C:\Windows\SystemTemp . |
ClearSessions | Deletes active sessions on Selenium grid. |
Close | Close the Browser and Dispose of WebDriver. |
Cookies | Gets Cookies object. |
CreateDriver | This will create a WebDriver for currently selected Browser profile. |
CreateDriverForSession | Connects to active Selenium session with given URL and Id. |
CreatePointerInput | Gets PointerInputDevice object. |
Dispose | Dispose of WebDriver. |
DownloadDriver | This will download required binary (e.g. |
DumpSessions | Prints information about active Selenium sessions to output. |
ExecuteScript | Executes JavaScript in the context of the currently selected frame or window. |
FindElement | Finds the first element on the page that matches By selector. |
FindElementByClassName | Finds the first element on the page that matches the CSS Class supplied. |
FindElementByCssSelector | Finds the first element matching the specified CSS selector. |
FindElementById | Finds the first element on the page that matches the ID supplied. |
FindElementByLinkText | Finds the first of elements that match the link text supplied. |
FindElementByName | Finds the first of elements that match the name supplied. |
FindElementByPartialLinkText | Finds the first of elements that match the part of the link text supplied. |
FindElementByTagName | Finds the first of elements that match the DOM Tag supplied. |
FindElementByXPath | Finds the first of elements that match the XPath supplied. |
FindElements | Finds a list of elements that match the supplied By object. |
FindElementsByClassName | Finds a list of elements that match the class name supplied. |
FindElementsByCssSelector | Finds all elements matching the specified CSS selector. |
FindElementsById | Finds the first element on the page that matches the ID supplied. |
FindElementsByLinkText | Finds a list of elements that match the link text supplied. |
FindElementsByName | Finds a list of elements that match the name supplied. |
FindElementsByPartialLinkText | Finds a list of elements that match the part of the link text supplied. |
FindElementsByTagName | Finds a list of elements that match the DOM Tag supplied. |
FindElementsByXPath | Finds a list of elements that match the XPath supplied. |
GetAddressOfRemoteServer | |
GetBrowserVersion | |
GetCurrentWindowHandle | Gets the current window handle, which is an opaque handle to this window that uniquely identifies it within this driver instance. |
GetDebuggerAddress | |
GetPageSource | Gets the source of the page last loaded by the browser. |
GetScreenshot | Gets the screenshot of the page. |
GetSessionId | |
GetTitle | Gets the title of the current browser window. |
GetUrl | Gets the URL the browser is currently displaying. |
GetWindowHandles | Gets the window handles of open browser windows. |
Navigate | Gets Navigation object with the following actions: Back, Forward, Refresh, GotToUrl(url). |
PerformActions | Performs W3C actions. |
Quit | Disconnects from the Browser. |
ReconnectSession | Reads session information produced by SaveSession and connects to the mobile target. |
SaveSession | Saves session information for use by ReconnectSession. |
SetBrowserSize | Sets size of a browser window. |
SetUrl | Sets the URL the browser is currently displaying. |
SwitchToAlert | Switches to the currently active modal dialog for this particular driver instance. |
SwitchToDefaultContent | Change the active frame to the default. |
SwitchToFrame | Move to different frame using its element. |
SwitchToLastWindow | Switch to last browser window. |
SwitchToParentFrame | Select the parent frame of the currently selected frame. |
SwitchToWindow | Switch to window specified by handle. |
Window | Gets Window object. |
Action Detail¶
Actions¶
Gets Actions object.
WebDriver.Actions()
AlertIsPresent¶
Checks if alert is displayed.
WebDriver.AlertIsPresent()
Cleanup¶
Cleans up folders created by temporary Chrome profiles in C:\Windows\SystemTemp
. These folders are named as scoped_dir* and may occupy significant disk space. Requires Rapise 8.3+.
WebDriver.Cleanup()
ClearSessions¶
Deletes active sessions on Selenium grid.
WebDriver.ClearSessions()
Close¶
Close the Browser and Dispose of WebDriver.
WebDriver.Close()
Cookies¶
Gets Cookies object.
WebDriver.Cookies()
CreateDriver¶
This will create a WebDriver for currently selected Browser profile.
WebDriver.CreateDriver(nonProfileCapsJson)
Parameters:
Name | Type | Description |
---|---|---|
nonProfileCapsJson | object | JSON object with capabilities not available in a Browser profile. |
Returns:
WebDriver object.
CreateDriverForSession¶
Connects to active Selenium session with given URL and Id.
WebDriver.CreateDriverForSession(addressOfRemoteServer, sessionId, driverServiceProcessId, debuggerAddress, browserVersion)
Parameters:
Name | Type | Description |
---|---|---|
addressOfRemoteServer | Selenium server URL. | |
sessionId | Id of the session to connect. | |
driverServiceProcessId | Process id for the driver executable. | |
debuggerAddress | Debugger address for DevTools connection. | |
browserVersion | Browser version for DevTools connection. |
Returns:
true if successful, false otherwise.
CreatePointerInput¶
Gets PointerInputDevice object. Requires Rapise 8.2+.
var element = WebDriver.FindElementByXPath("//button[@id='Login']");
var p = WebDriver.CreatePointerInput("Mouse", "pointer");
var sequence = p.CreateActionSequence(p);
var move = p.CreatePointerMoveElement(element, 5, 5, 0);
var actionPress = p.CreatePointerDown("Left");
var pause = p.CreatePause(50);
var actionRelease = p.CreatePointerUp("Left");
sequence.AddAction(move);
sequence.AddAction(actionPress);
sequence.AddAction(pause);
sequence.AddAction(actionRelease);
WebDriver.PerformActions(sequence);
WebDriver.CreatePointerInput(kind, name)
Parameters:
Name | Type | Description |
---|---|---|
kind | string | Touch, Mouse or Pen. |
name | string | Name of the pointer device. Whatever you like. |
Dispose¶
Dispose of WebDriver.
WebDriver.Dispose()
DownloadDriver¶
This will download required binary (e.g. chromedriver.exe) for currently selected Browser profile. Requires Rapise 7.2+
WebDriver.DownloadDriver(driverVersion)
Parameters:
Name | Type | Description |
---|---|---|
driverVersion | string | Version of the driver executable. Optional. |
Returns:
true
if successful, otherwise - false
.
DumpSessions¶
Prints information about active Selenium sessions to output.
WebDriver.DumpSessions()
ExecuteScript¶
Executes JavaScript in the context of the currently selected frame or window.
WebDriver.ExecuteScript(script, args)
Parameters:
Name | Type | Description |
---|---|---|
script | string | The JavaScript code to execute. |
args | array | The arguments to the script. |
Returns:
Null, string or element depending on the script.
FindElement¶
Finds the first element on the page that matches By selector. Requires Rapise 8.3+.
WebDriver.FindElement(by, by)
Parameters:
Name | Type | Description |
---|---|---|
by | By | By object. |
by | By | By object |
Returns:
element or null.
FindElementByClassName¶
Finds the first element on the page that matches the CSS Class supplied.
WebDriver.FindElementByClassName(className)
Parameters:
Name | Type | Description |
---|---|---|
className | string | CSS class name of the element. |
Returns:
element or null.
FindElementByCssSelector¶
Finds the first element matching the specified CSS selector.
WebDriver.FindElementByCssSelector(cssSelector)
Parameters:
Name | Type | Description |
---|---|---|
cssSelector | string | The CSS selector to match. |
Returns:
element ot null.
FindElementById¶
Finds the first element on the page that matches the ID supplied.
WebDriver.FindElementById(id)
Parameters:
Name | Type | Description |
---|---|---|
id | string | ID of the element. |
Returns:
element or null.
FindElementByLinkText¶
Finds the first of elements that match the link text supplied.
WebDriver.FindElementByLinkText(linkText)
Parameters:
Name | Type | Description |
---|---|---|
linkText | string | Link text of element. |
Returns:
element or null.
FindElementByName¶
Finds the first of elements that match the name supplied.
WebDriver.FindElementByName(name)
Parameters:
Name | Type | Description |
---|---|---|
name | string | Name of the element on the page. |
Returns:
element or null.
FindElementByPartialLinkText¶
Finds the first of elements that match the part of the link text supplied.
WebDriver.FindElementByPartialLinkText(partialLinkText)
Parameters:
Name | Type | Description |
---|---|---|
partialLinkText | string | Part of the link text. |
Returns:
element or null.
FindElementByTagName¶
Finds the first of elements that match the DOM Tag supplied.
WebDriver.FindElementByTagName(tagName)
Parameters:
Name | Type | Description |
---|---|---|
tagName | string | DOM tag Name of the element being searched. |
Returns:
element or null.
FindElementByXPath¶
Finds the first of elements that match the XPath supplied.
WebDriver.FindElementByXPath(xpath)
Parameters:
Name | Type | Description |
---|---|---|
xpath | string | xpath to the element. |
Returns:
element or null.
FindElements¶
Finds a list of elements that match the supplied By object. Requires Rapise 8.3+.
WebDriver.FindElements(by, by)
Parameters:
Name | Type | Description |
---|---|---|
by | By | By object. |
by | By | By object |
Returns:
array of elements.
FindElementsByClassName¶
Finds a list of elements that match the class name supplied.
WebDriver.FindElementsByClassName(className)
Parameters:
Name | Type | Description |
---|---|---|
className | string | className of the element. |
Returns:
array of elements.
FindElementsByCssSelector¶
Finds all elements matching the specified CSS selector.
WebDriver.FindElementsByCssSelector(cssSelector)
Parameters:
Name | Type | Description |
---|---|---|
cssSelector | string | The CSS selector to match. |
Returns:
array of elements.
FindElementsById¶
Finds the first element on the page that matches the ID supplied.
WebDriver.FindElementsById(id)
Parameters:
Name | Type | Description |
---|---|---|
id | string | ID of the element. |
Returns:
array of elements.
FindElementsByLinkText¶
Finds a list of elements that match the link text supplied.
WebDriver.FindElementsByLinkText(linkText)
Parameters:
Name | Type | Description |
---|---|---|
linkText | Link text of element. |
Returns:
array of elements.
FindElementsByName¶
Finds a list of elements that match the name supplied.
WebDriver.FindElementsByName(name)
Parameters:
Name | Type | Description |
---|---|---|
name | string | Name of the element on the page. |
Returns:
array of elements.
FindElementsByPartialLinkText¶
Finds a list of elements that match the part of the link text supplied.
WebDriver.FindElementsByPartialLinkText(partialLinkText)
Parameters:
Name | Type | Description |
---|---|---|
partialLinkText | string | Part of the link text. |
Returns:
array of elements.
FindElementsByTagName¶
Finds a list of elements that match the DOM Tag supplied.
WebDriver.FindElementsByTagName(tagName)
Parameters:
Name | Type | Description |
---|---|---|
tagName | string | DOM tag Name of the element being searched. |
Returns:
array of elements.
FindElementsByXPath¶
Finds a list of elements that match the XPath supplied.
WebDriver.FindElementsByXPath(xpath)
Parameters:
Name | Type | Description |
---|---|---|
xpath | string | xpath to the element. |
Returns:
array of elements.
GetAddressOfRemoteServer¶
WebDriver.GetAddressOfRemoteServer()
Returns:
URL of the remote Selenium server.
GetBrowserVersion¶
WebDriver.GetBrowserVersion()
Returns:
browser version of the remote Selenium server.
GetCurrentWindowHandle¶
Gets the current window handle, which is an opaque handle to this window that uniquely identifies it within this driver instance.
WebDriver.GetCurrentWindowHandle()
GetDebuggerAddress¶
WebDriver.GetDebuggerAddress()
Returns:
debugger address of the remote Selenium server.
GetPageSource¶
Gets the source of the page last loaded by the browser.
WebDriver.GetPageSource()
GetScreenshot¶
Gets the screenshot of the page.
WebDriver.GetScreenshot()
GetSessionId¶
WebDriver.GetSessionId()
Returns:
Id of the current session.
GetTitle¶
Gets the title of the current browser window.
WebDriver.GetTitle()
GetUrl¶
Gets the URL the browser is currently displaying.
WebDriver.GetUrl()
GetWindowHandles¶
Gets the window handles of open browser windows.
WebDriver.GetWindowHandles()
Navigate¶
Gets Navigation object with the following actions: Back, Forward, Refresh, GotToUrl(url).
Example:
WebDriver.Navigate().Back();
WebDriver.Navigate()
PerformActions¶
Performs W3C actions. Requires Rapise 8.2+. See CreatePointerInput for usage example.
WebDriver.PerformActions(sequence)
Parameters:
Name | Type | Description |
---|---|---|
sequence | ActionSequence | Array of ActionSequence objects. |
Quit¶
Disconnects from the Browser.
WebDriver.Quit()
ReconnectSession¶
Reads session information produced by SaveSession and connects to the mobile target.
WebDriver.ReconnectSession(autoCreate)
Parameters:
Name | Type | Description |
---|---|---|
autoCreate | boolean | 'true' to automatically create a new session if there is no saved session or saved session is not available anymore. Optional, Default: "false". |
SaveSession¶
Saves session information for use by ReconnectSession.
WebDriver.SaveSession()
SetBrowserSize¶
Sets size of a browser window.
WebDriver.SetBrowserSize(width, height)
Parameters:
Name | Type | Description |
---|---|---|
width | number | Window width to set |
height | number | Window height to set |
SetUrl¶
Sets the URL the browser is currently displaying.
WebDriver.SetUrl(url)
Parameters:
Name | Type | Description |
---|---|---|
url | string | The URL to display |
SwitchToAlert¶
Switches to the currently active modal dialog for this particular driver instance.
WebDriver.SwitchToAlert()
SwitchToDefaultContent¶
Change the active frame to the default.
WebDriver.SwitchToDefaultContent()
SwitchToFrame¶
Move to different frame using its element.
WebDriver.SwitchToFrame(el)
Parameters:
Name | Type | Description |
---|---|---|
el | WebElementWrapper | Element of the frame. |
SwitchToLastWindow¶
Switch to last browser window.
WebDriver.SwitchToLastWindow()
SwitchToParentFrame¶
Select the parent frame of the currently selected frame.
WebDriver.SwitchToParentFrame()
SwitchToWindow¶
Switch to window specified by handle.
WebDriver.SwitchToWindow(windowHandle)
Parameters:
Name | Type | Description |
---|---|---|
windowHandle |
Window¶
Gets Window object.
WebDriver.Window()