WebDriver Protocol
newSession
The New Session command creates a new WebDriver session with the endpoint node. If the creation fails, a session not created error is returned.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usage
browser.newSession(capabilities)
Parameters
Name | Type | Details |
---|---|---|
capabilities | object | a JSON object, the set of capabilities that was ultimately merged and matched in the capability processing algorithm |
Returns
- <Object>
session
: Object containing sessionId and capabilities of created WebDriver session.
deleteSession
The Delete Session command closes any top-level browsing contexts associated with the current session, terminates the connection, and finally closes the current session.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usage
browser.deleteSession(deleteSessionOpts)
Parameters
Name | Type | Details |
---|---|---|
deleteSessionOpts optional | object | Object containing options for the deleteSession command, e.g. { shutdownDriver: boolean } |
status
The Status command returns information about whether a remote end is in a state in which it can create new sessions and can additionally include arbitrary meta information that is specific to the implementation.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usage
browser.status()
Example
loading...
Returns
- <Object>
status
: Object containing status of the driver status.
getTimeouts
The Get Timeouts command gets timeout durations associated with the current session.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usage
browser.getTimeouts()
Example
loading...
Returns
- <Object>
timeouts
: Object containing timeout durations forscript
,pageLoad
andimplicit
timeouts.
setTimeouts
The Set Timeouts command sets timeout durations associated with the current session. The timeouts that can be controlled are listed in the table of session timeouts below.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usage
browser.setTimeouts(implicit, pageLoad, script)
Parameters
Name | Type | Details |
---|---|---|
implicit optional | number | integer in ms for session implicit wait timeout |
pageLoad optional | number | integer in ms for session page load timeout |
script optional | number | integer in ms for session script timeout |
Example
loading...
getUrl
The Get Current URL command returns the URL of the current top-level browsing context.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usage
browser.getUrl()
Example
loading...
Returns
- <string>
url
: current top-level browsing context’s active document’s document URL
navigateTo
The navigateTo (go) command is used to cause the user agent to navigate the current top-level browsing context a new location.
WebDriver Protocol command. More details can be found in the official protocol docs.
This protocol command is embedded in the following convenient method: url}. It is recommended to use this command instead.
Usage
browser.navigateTo(url)
Parameters
Name | Type | Details |
---|---|---|
url | string | string representing an absolute URL (beginning with http(s)), possibly including a fragment (#...), could also be a local scheme (about: etc) |
Example
loading...
Returns
- <string>
url
: current document URL of the top-level browsing context.
back
The Back command causes the browser to traverse one step backward in the joint session history of the current top-level browsing context. This is equivalent to pressing the back button in the browser chrome or calling window.history.back
.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usage
browser.back()
Example
loading...
forward
The Forward command causes the browser to traverse one step forwards in the joint session history of the current top-level browsing context.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usage
browser.forward()
Example
loading...
refresh
The Refresh command causes the browser to reload the page in current top-level browsing context.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usage
browser.refresh()
Example
loading...
getTitle
The Get Title command returns the document title of the current top-level browsing context, equivalent to calling document.title
.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usage
browser.getTitle()
Example
loading...
Returns
- <string>
title
: Returns a string which is the same asdocument.title
of the current top-level browsing context.
getWindowHandle
The Get Window Handle command returns the window handle for the current top-level browsing context. It can be used as an argument to Switch To Window.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usage
browser.getWindowHandle()
Example
loading...
Returns
- <string>
handle
: Returns a string which is the window handle for the current top-level browsing context.
closeWindow
The Close Window command closes the current top-level browsing context. Once done, if there are no more top-level browsing contexts open, the WebDriver session itself is closed.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usage
browser.closeWindow()
Example
loading...
switchToWindow
The Switch To Window command is used to select the current top-level browsing context for the current session, i.e. the one that will be used for processing commands.
WebDriver Protocol command. More details can be found in the official protocol docs.
This protocol command is embedded in the following convenient method: switchWindow}. It is recommended to use this command instead.
Usage
browser.switchToWindow(handle)
Parameters
Name | Type | Details |
---|---|---|
handle | string | a string representing a window handle, should be one of the strings that was returned in a call to getWindowHandles |
Example
loading...
createWindow
Create a new top-level browsing context.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usage
browser.createWindow(type)