JSON Wire Protocol
The JSONWireProtocol is deprecated and replaced by the WebDriver protocol.
status
Query the server's current status. The server should respond with a general "HTTP 200 OK" response if it is alive and accepting commands. The response body should be a JSON object describing the state of the server. All server implementations should return two basic objects describing the server's current platform and when the server was built. All fields are optional; if omitted, the client should assume the value is unknown. Furthermore, server implementations may include additional fields not listed here.
JSON Wire Protocol command. More details can be found in the official protocol docs.
Usage
browser.status()
Returns
- <Object>
status
: An object describing the general status of the server.
newSession
Create a new session. The server should attempt to create a session that most closely matches the desired and required capabilities. Required capabilities have higher priority than desired capabilities and must be set for the session to be created.
JSON Wire Protocol command. More details can be found in the official protocol docs.
Usage
browser.newSession(desiredCapabilities, requiredCapabilities)
Parameters
Name | Type | Details |
---|---|---|
desiredCapabilities | object | An object describing the session's desired capabilities. |
requiredCapabilities optional | object | An object describing the session's required capabilities (Optional). |
Returns
- <Object>
capabilities
: An object describing the session's capabilities.
getSessions
Returns a list of the currently active sessions. Each session will be returned as a list of JSON objects containing id
and capabilities
.
JSON Wire Protocol command. More details can be found in the official protocol docs.
This protocol command is deprecated
This command is deprecated and likely not supported by any browser.
Usage
browser.getSessions()
Returns
- <Object[]>
capabilities
: A list of the currently active sessions.
getSession
Retrieve the capabilities of the specified session.
JSON Wire Protocol command. More details can be found in the official protocol docs.
This protocol command is deprecated
This command is deprecated and likely not supported by any browser.
Usage
browser.getSession()
Returns
- <Object>
capabilities
: An object describing the session's capabilities.
deleteSession
Delete the session.
JSON Wire 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 } |
setTimeouts
Configure the amount of time that a particular type of operation can execute for before they are aborted and a |Timeout| error is returned to the client.
JSON Wire Protocol command. More details can be found in the official protocol docs.
Usage
browser.setTimeouts(type, ms)
Parameters
Name | Type | Details |
---|---|---|
type | string | The type of operation to set the timeout for. Valid values are: "script" for script timeouts, "implicit" for modifying the implicit wait timeout and "page load" for setting a page load timeout. |
ms | number | The amount of time, in milliseconds, that time-limited commands are permitted to run |
setAsyncTimeout
Set the amount of time, in milliseconds, that asynchronous scripts executed by /session/:sessionId/execute_async
are permitted to run before they are aborted and a Timeout
error is returned to the client.
JSON Wire Protocol command. More details can be found in the official protocol docs.
This protocol command is deprecated
This command is deprecated and likely not supported by any browser. Use the "setTimeouts" command instead!
Usage
browser.setAsyncTimeout(ms)
Parameters
Name | Type | Details |
---|---|---|
ms | number | The amount of time, in milliseconds, that time-limited commands are permitted to run |
setImplicitTimeout
Set the amount of time the driver should wait when searching for elements. When searching for a single element, the driver should poll the page until an element is found or the timeout expires, whichever occurs first. When searching for multiple elements, the driver should poll the page until at least one element is found or the timeout expires, at which point it should return an empty list. If this command is never sent, the driver should default to an implicit wait of 0ms.
JSON Wire Protocol command. More details can be found in the official protocol docs.
This protocol command is deprecated
This command is deprecated and likely not supported by any browser. Use the "setTimeouts" command instead!
Usage
browser.setImplicitTimeout(ms)
Parameters
Name | Type | Details |
---|---|---|
ms | number | The amount of time, in milliseconds, to wait on an element. |
getUrl
Retrieve the URL of the current page.
JSON Wire Protocol command. More details can be found in the official protocol docs.
Usage
browser.getUrl()
Returns
- <String>
url
: The current URL.
navigateTo
Navigate to a new URL.
JSON Wire Protocol command. More details can be found in the official protocol docs.
Usage
browser.navigateTo(url)
Parameters
Name | Type | Details |
---|---|---|
url | string | The URL to navigate to. |
back
Navigate backwards in the browser history, if possible.
JSON Wire Protocol command. More details can be found in the official protocol docs.
Usage
browser.back()
forward
Navigate forwards in the browser history, if possible.
JSON Wire Protocol command. More details can be found in the official protocol docs.
Usage
browser.forward()
refresh
Refresh the current page.
JSON Wire Protocol command. More details can be found in the official protocol docs.
Usage
browser.refresh()
getTitle
Get the current page title.
JSON Wire Protocol command. More details can be found in the official protocol docs.
Usage
browser.getTitle()
Returns
- <String>
title
: The current page title.
getWindowHandle
Retrieve the current window handle.
JSON Wire Protocol command. More details can be found in the official protocol docs.
Usage
browser.getWindowHandle()
Returns
- <String>
windowHandle
: The current window handle.
getWindowHandles
Retrieve the list of all window handles available to the session.
JSON Wire Protocol command. More details can be found in the official protocol docs.
Usage
browser.getWindowHandles()
Returns
- <String[]>
windowHandles
: A list of window handles.
closeWindow
Close the current window.
JSON Wire Protocol command. More details can be found in the official protocol docs.
Usage
browser.closeWindow()
switchToWindow
Change focus to another window. The window to change focus to may be specified by its server assigned window handle, or by the value of its name
attribute.
JSON Wire Protocol command. More details can be found in the official protocol docs.
Usage
browser.switchToWindow(name)
Parameters
Name | Type | Details |
---|---|---|
name | string | The window to change focus to |
switchToFrame
Change focus to another frame on the page. If the frame id
is null
, the server should switch to the page's default content.
JSON Wire Protocol command. More details can be found in the official protocol docs.
Usage
browser.switchToFrame(id)
Parameters
Name | Type | Details |
---|---|---|
id | string, number, object, null | Identifier for the frame to change focus to |
switchToParentFrame
Change focus to the parent context. If the current context is the top level browsing context, the context remains unchanged.
JSON Wire Protocol command. More details can be found in the official protocol docs.
Usage
browser.switchToParentFrame()
getWindowPosition
Get the position of the current focussed window.
JSON Wire Protocol command. More details can be found in the official protocol docs.
This protocol command is deprecated
This command is deprecated and likely not supported by any browser.
Usage
browser.getWindowPosition()
Returns
- <Object>
positon
: The X and Y coordinates for the window, relative to the upper left corner of the screen.
setWindowPosition
Change the position of the current focussed window.
JSON Wire Protocol command. More details can be found in the official protocol docs.
This protocol command is deprecated
This command is deprecated and likely not supported by any browser.
Usage
browser.setWindowPosition(x, y)
Parameters
Name | Type | Details |
---|---|---|
x | number | The X coordinate to position the window at, relative to the upper left corner of the screen. |
y | number | The Y coordinate to position the window at, relative to the upper left corner of the screen. |
Returns
- <Object>
positon
: The X and Y coordinates for the window, relative to the upper left corner of the screen.
_getWindowSize
Get the size of the current focused window.
JSON Wire Protocol command. More details can be found in the official protocol docs.
This protocol command is deprecated
This command is deprecated and likely not supported by any browser.
Usage
browser._getWindowSize()
Returns
- <Object>
size
: The size of the window.
_setWindowSize
Change the size of the current focused window.
JSON Wire Protocol command. More details can be found in the official protocol docs.
This protocol command is deprecated
This command is deprecated and likely not supported by any browser.
Usage
browser._setWindowSize(width, height)
Parameters
Name | Type | Details |
---|---|---|
width | number | the new window width |
height | number | the new window height |
maximizeWindow
Maximize the current focused window if not already maximized.
JSON Wire Protocol command. More details can be found in the official protocol docs.
Usage
browser.maximizeWindow()
findElement
Search for an element on the page, starting from the document root. The located element will be returned as a WebElement JSON object. The table below lists the locator strategies that each server should support. Each locator must return the first matching element located in the DOM.
JSON Wire Protocol command. More details can be found in the official protocol docs.
Usage
browser.findElement(using, value)
Parameters
Name | Type | Details |
---|---|---|
using | string | the locator strategy to use |
value | string | the search target |
Returns
- <object>
ELEMENT
: A WebElement JSON object for the located element.
findElements
Search for multiple elements on the page, starting from the document root. The located elements will be returned as a WebElement JSON objects. The table below lists the locator strategies that each server should support. Elements should be returned in the order located in the DOM.
JSON Wire Protocol command. More details can be found in the official protocol docs.
Usage
browser.findElements(using, value)
Parameters
Name | Type | Details |
---|---|---|
using | string | the locator strategy to use |
value | string | the search target |
Returns
- <object[]>
ELEMENTS
: A list of WebElement JSON objects for the located elements.
findElementFromElement
Search for an element on the page, starting from the identified element. The located element will be returned as a WebElement JSON object. The table below lists the locator strategies that each server should support. Each locator must return the first matching element located in the DOM.
JSON Wire Protocol command. More details can be found in the official protocol docs.
Usage
browser.findElementFromElement(elementId, using, value)
Parameters
Name | Type | Details |
---|---|---|
elementId | String | ID of the element to route the command to |
using | string | the locator strategy to use |
value | string | the search target |
Returns
- <object>
ELEMENT
: A WebElement JSON object for the located element.
findElementsFromElement
Search for multiple elements on the page, starting from the identified element. The located elements will be returned as a WebElement JSON objects. The table below lists the locator strategies that each server should support. Elements should be returned in the order located in the DOM.
JSON Wire Protocol command. More details can be found in the official protocol docs.
Usage
browser.findElementsFromElement(elementId, using, value)
Parameters
Name | Type | Details |
---|---|---|
elementId | String | ID of the element to route the command to |
using | string | the locator strategy to use |
value | string | the search target |
Returns
- <object[]>
ELEMENTS
: A list of WebElement JSON objects for the located elements.
getActiveElement
Get the element on the page that currently has focus. The element will be returned as a WebElement JSON object.
JSON Wire Protocol command. More details can be found in the official protocol docs.