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...
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)
Parametersโ
Name | Type | Details |
---|---|---|
type | string | Set to 'tab' if the newly created window shares an OS-level window with the current browsing context, or 'window' otherwise. |
Exampleโ
loading...
Returnsโ
- <Object>
window
: New window object containing 'handle' with the value of the handle and 'type' with the value of the created window type
getWindowHandlesโ
The Get Window Handles command returns a list of window handles for every open top-level browsing context. The order in which the window handles are returned is arbitrary.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.getWindowHandles()
Exampleโ
loading...
Returnsโ
- <String[]>
handles
: An array which is a list of window handles.
printPageโ
The Print Page command renders the document to a paginated PDF document. Note: Chrome currently only supports this in headless mode, see crbug753118
).
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.printPage(orientation, scale, background, width, height, top, bottom, left, right, shrinkToFit, pageRanges)
Parametersโ
Name | Type | Details |
---|---|---|
orientation optional | string | page orientation. Default: portrait |
scale optional | number | page scale. Default: 1 |
background optional | boolean | page background. Default: false |
width optional | number | page width in cm. Default: 21.59 from page |
height optional | number | page height in cm. Default: 27.94 from page |
top optional | number | page margin in cm from top margin. Default: 1 |
bottom optional | number | page margin in cm from bottom margin. Default: 1 |
left optional | number | page margin in cm from left margin. Default: 1 |
right optional | number | page margin in cm from right margin. Default: 1 |
shrinkToFit optional | boolean | shrink pdf to fit in page. Default: true |
pageRanges optional | object[] | page ranges. Default [] |
Exampleโ
loading...
Returnsโ
- <string>
pdf
: The base64-encoded PDF representation of the paginated document.
switchToFrameโ
The Switch To Frame command is used to select the current top-level browsing context or a child browsing context of the current browsing context to use as the current browsing context for subsequent commands.
WebDriver Protocol command. More details can be found in the official protocol docs.
This protocol command is deprecated
This command is deprecated and we encourage everyone to use switchFrame
instead for switching into frames. Read more about this command at https://webdriver.io/docs/api/browser/switchFrame.
Usageโ
browser.switchToFrame(id)
Parametersโ
Name | Type | Details |
---|---|---|
id | number, object, null | one of three possible types: null: this represents the top-level browsing context (i.e., not an iframe), a Number, representing the index of the window object corresponding to a frame, an Element object received using findElement . |
Exampleโ
loading...
switchToParentFrameโ
The Switch to Parent Frame command sets the current browsing context for future commands to the parent of the current browsing context.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.switchToParentFrame()
Exampleโ
loading...
getWindowRectโ
The Get Window Rect command returns the size and position on the screen of the operating system window corresponding to the current top-level browsing context.
WebDriver Protocol command. More details can be found in the official protocol docs.
This protocol command is embedded in the following convenient method: getWindowSize. It is recommended to use this command instead.
Usageโ
browser.getWindowRect()
Exampleโ
loading...
Returnsโ
- <Object>
windowRect
: A JSON representation of a "window rect" object. This has 4 properties:x
,y
,width
andheight
.
setWindowRectโ
The Set Window Rect command alters the size and the position of the operating system window corresponding to the current top-level browsing context.
WebDriver Protocol command. More details can be found in the official protocol docs.
This protocol command is embedded in the following convenient method: setWindowSize. It is recommended to use this command instead.
Usageโ
browser.setWindowRect(x, y, width, height)
Parametersโ
Name | Type | Details |
---|---|---|
x | number, null | the screenX attribute of the window object |
y | number, null | the screenY attribute of the window object |
width | number, null | the width of the outer dimensions of the top-level browsing context, including browser chrome etc... |
height | number, null | the height of the outer dimensions of the top-level browsing context, including browser chrome etc... |
Exampleโ
loading...
Returnsโ
- <Object>
windowRect
: A JSON representation of a "window rect" object based on the new window state.
maximizeWindowโ
The Maximize Window command invokes the window manager-specific "maximize" operation, if any, on the window containing the current top-level browsing context. This typically increases the window to the maximum available size without going full-screen.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.maximizeWindow()
Exampleโ
loading...
Returnsโ
- <Object>
windowRect
: A JSON representation of a "window rect" object based on the new window state.
minimizeWindowโ
The Minimize Window command invokes the window manager-specific "minimize" operation, if any, on the window containing the current top-level browsing context. This typically hides the window in the system tray.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.minimizeWindow()
Returnsโ
- <Object>
windowRect
: A JSON representation of a "window rect" object of the (new) current top-level browsing context.
fullscreenWindowโ
The Fullscreen Window command invokes the window manager-specific โfull screenโ operation, if any, on the window containing the current top-level browsing context. This typically increases the window to the size of the physical display and can hide browser chrome elements such as toolbars.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.fullscreenWindow()
Returnsโ
- <Object>
windowRect
: A JSON representation of a "window rect" object of the (new) current top-level browsing context.
findElementโ
The Find Element command is used to find an element in the current browsing context that can be used for future commands. This command returns JSON representation of the element that can be passed to $ command to transform the reference to an extended WebdriverIO element.
WebDriver Protocol command. More details can be found in the official protocol docs.
This protocol command is embedded in the following convenient method: $. It is recommended to use this command instead.
Usageโ
browser.findElement(using, value)
Parametersโ
Name | Type | Details |
---|---|---|
using | string | a valid element location strategy |
value | string | the actual selector that will be used to find an element |
Exampleโ
loading...
Returnsโ
- <object>
element
: A JSON representation of an element object, e.g.{ 'element-6066-11e4-a52e-4f735466cecf': 'ELEMENT_1' }
.
findElementFromShadowRootโ
The Find Element From Shadow Root command is used to find an element within the shadow root of an element that can be used for future commands. This command returns JSON representation of the element that can be passed to $ command to transform the reference to an extended WebdriverIO element.
WebDriver Protocol command. More details can be found in the official protocol docs.
This protocol command is embedded in the following convenient method: shadow$. It is recommended to use this command instead.
Usageโ
browser.findElementFromShadowRoot(shadowId, using, value)
Parametersโ
Name | Type | Details |
---|---|---|
shadowId | String | element id of a shadow root element |
using | string | a valid element location strategy |
value | string | the actual selector that will be used to find an element |
Exampleโ
loading...
Returnsโ
- <object>
element
: A JSON representation of an element shadow object, e.g.{ 'element-6066-11e4-a52e-4f735466cecf': 'ELEMENT_1' }
.
findElementsโ
The Find Elements command is used to find elements in the current browsing context that can be used for future commands. This command returns array of JSON representation of the elements that can be passed to $ command to transform the reference to an extended WebdriverIO element (See findElement).
WebDriver Protocol command. More details can be found in the official protocol docs.
This protocol command is embedded in the following convenient method: $$. It is recommended to use this command instead.
Usageโ
browser.findElements(using, value)
Parametersโ
Name | Type | Details |
---|---|---|
using | string | a valid element location strategy |
value | string | the actual selector that will be used to find an element |
Exampleโ
loading...
Returnsโ
- <object[]>
elements
: A (possibly empty) JSON list of representations of an element object, e.g.[{ 'element-6066-11e4-a52e-4f735466cecf': 'ELEMENT_1' }]
.
findElementsFromShadowRootโ
The Find Elements command is used to find elements within the shadow root of an element that can be used for future commands. This command returns array of JSON representation of the elements that can be passed to $ command to transform the reference to an extended WebdriverIO element (See findElement).
WebDriver Protocol command. More details can be found in the official protocol docs.
This protocol command is embedded in the following convenient method: shadow$$. It is recommended to use this command instead.
Usageโ
browser.findElementsFromShadowRoot(shadowId, using, value)
Parametersโ
Name | Type | Details |
---|---|---|
shadowId | String | element id of a shadow root element |
using | string | a valid element location strategy |
value | string | the actual selector that will be used to find an element |
Exampleโ
loading...
Returnsโ
- <object[]>
elements
: A (possibly empty) JSON list of representations of an element object, e.g.{ 'element-6066-11e4-a52e-4f735466cecf': 'ELEMENT_1' }
.
findElementFromElementโ
The Find Element From Element command is used to find an element from a web element in the current browsing context that can be used for future commands. This command returns JSON representation of the element that can be passed to $ command to transform the reference to an extended WebdriverIO element (See findElement).
WebDriver Protocol command. More details can be found in the official protocol docs.
This protocol command is embedded in the following convenient method: $. It is recommended to use this command instead.
Usageโ
browser.findElementFromElement(elementId, using, value)
Parametersโ
Name | Type | Details |
---|---|---|
elementId | String | the id of an element returned in a previous call to Find Element(s) |
using | string | a valid element location strategy |
value | string | the actual selector that will be used to find an element |
Exampleโ
loading...
Returnsโ
- <object>
element
: A JSON representation of an element object, e.g.{ 'element-6066-11e4-a52e-4f735466cecf': 'ELEMENT_1' }
.
findElementsFromElementโ
The Find Elements From Element command is used to find elements from a web element in the current browsing context that can be used for future commands. This command returns array of JSON representation of the elements that can be passed to $ command to transform the reference to an extended WebdriverIO element (See findElement).
WebDriver Protocol command. More details can be found in the official protocol docs.
This protocol command is embedded in the following convenient method: $$. It is recommended to use this command instead.
Usageโ
browser.findElementsFromElement(elementId, using, value)
Parametersโ
Name | Type | Details |
---|---|---|
elementId | String | the id of an element returned in a previous call to Find Element(s) |
using | string | a valid element location strategy |
value | string | the actual selector that will be used to find an element |
Exampleโ
loading...
Returnsโ
- <object[]>
elements
: A (possibly empty) JSON list of representations of an element object, e.g.[{ 'element-6066-11e4-a52e-4f735466cecf': 'ELEMENT_1' }]
.
getElementShadowRootโ
Get the shadow root object of an element. The result object can be used to fetch elements within this shadow root using e.g. findElementFromShadowRoots or findElementsFromShadowRoots.
WebDriver Protocol command. More details can be found in the official protocol docs.
This protocol command is embedded in the following convenient method: shadow$. It is recommended to use this command instead.
Usageโ
browser.getElementShadowRoot(elementId)
Parametersโ
Name | Type | Details |
---|---|---|
elementId | String | the id of an element returned in a previous call to Find Element(s) |
Exampleโ
loading...
Returnsโ
- <string>
shadowRoot
: A JSON representation of an element shadow root, e.g.{ 'shadow-6066-11e4-a52e-4f735466cecf': 'ELEMENT_1' }
.
getActiveElementโ
Get Active Element returns the active element of the current browsing contextโs document element. This command returns JSON representation of the element that can be passed to $ command to transform the reference to an extended WebdriverIO element (See findElement).
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.getActiveElement()
Exampleโ
loading...
Returnsโ
- <string>
element
: A JSON representation of an element object, e.g.{ 'element-6066-11e4-a52e-4f735466cecf': 'ELEMENT_1' }
.
isElementSelectedโ
Is Element Selected determines if the referenced element is selected or not. This operation only makes sense on input elements of the Checkbox- and Radio Button states, or option elements.
WebDriver Protocol command. More details can be found in the official protocol docs.
This protocol command is embedded in the following convenient method: isSelected. It is recommended to use this command instead.
Usageโ
browser.isElementSelected(elementId)
Parametersโ
Name | Type | Details |
---|---|---|
elementId | String | the id of an element returned in a previous call to Find Element(s) |
Exampleโ
loading...
Returnsโ
- <Boolean>
isSelected
:true
orfalse
based on the selected state.
isElementDisplayedโ
Is Element Displayed determines the visibility of an element which is guided by what is perceptually visible to the human eye. In this context, an element's displayedness does not relate to the visibility
or display
style properties.
WebDriver Protocol command. More details can be found in the official protocol docs.
This protocol command is embedded in the following convenient method: isDisplayed. It is recommended to use this command instead.
Usageโ
browser.isElementDisplayed(elementId)
Parametersโ
Name | Type | Details |
---|---|---|
elementId | String | the id of an element returned in a previous call to Find Element(s) |
Exampleโ
loading...
Returnsโ
- <Boolean>
isDisplayed
:true
orfalse
based on the visible state.
getElementAttributeโ
The Get Element Attribute command will return the attribute of a web element.
WebDriver Protocol command. More details can be found in the official protocol docs.
This protocol command is embedded in the following convenient method: getAttribute. It is recommended to use this command instead.
Usageโ
browser.getElementAttribute(elementId, name)
Parametersโ
Name | Type | Details |
---|---|---|
elementId | String | the id of an element returned in a previous call to Find Element(s) |
name | String | name of the attribute value to retrieve |
Exampleโ
loading...
Returnsโ
- <string>
attribute
: The named attribute of the element.
getElementPropertyโ
The Get Element Property command will return the result of getting a property of an element.
WebDriver Protocol command. More details can be found in the official protocol docs.
This protocol command is embedded in the following convenient method: getProperty. It is recommended to use this command instead.
Usageโ
browser.getElementProperty(elementId, name)
Parametersโ
Name | Type | Details |
---|---|---|
elementId | String | the id of an element returned in a previous call to Find Element(s) |
name | String | name of the attribute property to retrieve |
Exampleโ
loading...
Returnsโ
- <string>
property
: The named property of the element, accessed by calling GetOwnProperty on the element object.
getElementCSSValueโ
The Get Element CSS Value command retrieves the computed value of the given CSS property of the given web element.
WebDriver Protocol command. More details can be found in the official protocol docs.
This protocol command is embedded in the following convenient method: getCSSProperty. It is recommended to use this command instead.
Usageโ
browser.getElementCSSValue(elementId, propertyName)
Parametersโ
Name | Type | Details |
---|---|---|
elementId | String | the id of an element returned in a previous call to Find Element(s) |
propertyName | String | name of the CSS property to retrieve |
Exampleโ
loading...
Returnsโ
- <string>
cssValue
: The computed value of the parameter corresponding to property name from the element's style declarations (unless the document type is xml, in which case the return value is simply the empty string).
getElementTextโ
The Get Element Text command intends to return an elementโs text "as rendered". An element's rendered text is also used for locating a elements by their link text and partial link text.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.getElementText(elementId)
Parametersโ
Name | Type | Details |
---|---|---|
elementId | String | the id of an element returned in a previous call to Find Element(s) |
Exampleโ
loading...
Returnsโ
- <string>
text
: The visible text of the element (including child elements), following the algorithm defined in the Selenium Atoms forbot.dom.getVisibleText
.
getElementTagNameโ
The Get Element Tag Name command returns the qualified element name of the given web element.
WebDriver Protocol command. More details can be found in the official protocol docs.
This protocol command is embedded in the following convenient method: getTagName. It is recommended to use this command instead.
Usageโ
browser.getElementTagName(elementId)
Parametersโ
Name | Type | Details |
---|---|---|
elementId | String | the id of an element returned in a previous call to Find Element(s) |
Exampleโ
loading...
Returnsโ
- <string>
text
: The tagName attribute of the element.
getElementRectโ
The Get Element Rect command returns the dimensions and coordinates of the given web element.
WebDriver Protocol command. More details can be found in the official protocol docs.
This protocol command is embedded in the following convenient methods: getSize, getLocation. It is recommended to use these commands instead.
Usageโ
browser.getElementRect(elementId)
Parametersโ
Name | Type | Details |
---|---|---|
elementId | String | the id of an element returned in a previous call to Find Element(s) |
Exampleโ
loading...
Returnsโ
- <Object>
elementRect
: A JSON object representing the position and bounding rect of the element.
isElementEnabledโ
Is Element Enabled determines if the referenced element is enabled or not. This operation only makes sense on form controls.
WebDriver Protocol command. More details can be found in the official protocol docs.
This protocol command is embedded in the following convenient method: isEnabled. It is recommended to use this command instead.
Usageโ
browser.isElementEnabled(elementId)
Parametersโ
Name | Type | Details |
---|---|---|
elementId | String | the id of an element returned in a previous call to Find Element(s) |
Exampleโ
loading...
Returnsโ
- <Boolean>
isEnabled
: If the element is in an xml document, or is a disabled form control:false
, otherwise,true
.
elementClickโ
The Element Click command scrolls into view the element if it is not already pointer-interactable, and clicks its in-view center point. If the element's center point is obscured by another element, an element click intercepted error is returned. If the element is outside the viewport, an element not interactable error is returned.
WebDriver Protocol command. More details can be found in the official protocol docs.
This protocol command is embedded in the following convenient method: click. It is recommended to use this command instead.
Usageโ
browser.elementClick(elementId)
Parametersโ
Name | Type | Details |
---|---|---|
elementId | String | the id of an element returned in a previous call to Find Element(s) |
Exampleโ
loading...
elementClearโ
The Element Clear command scrolls into view an editable or resettable element and then attempts to clear its selected files or text content.
WebDriver Protocol command. More details can be found in the official protocol docs.
This protocol command is embedded in the following convenient method: clearValue. It is recommended to use this command instead.
Usageโ
browser.elementClear(elementId)
Parametersโ
Name | Type | Details |
---|---|---|
elementId | String | the id of an element returned in a previous call to Find Element(s) |
Exampleโ
loading...
elementSendKeysโ
The Element Send Keys command scrolls into view the form control element and then sends the provided keys to the element. In case the element is not keyboard-interactable, an element not interactable error is returned.
The key input state used for input may be cleared mid-way through "typing" by sending the null key, which is U+E000 (NULL).
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.elementSendKeys(elementId, text)
Parametersโ
Name | Type | Details |
---|---|---|
elementId | String | the id of an element returned in a previous call to Find Element(s) |
text | string | string to send as keystrokes to the element |
Exampleโ
loading...
getPageSourceโ
The Get Page Source command returns a string serialization of the DOM of the current browsing context active document.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.getPageSource()
Exampleโ
loading...
Returnsโ
- <string>
pageSource
: the DOM of the current browsing context active document
executeScriptโ
The Execute Script command executes a JavaScript function in the context of the current browsing context and returns the return value of the function.
WebDriver Protocol command. More details can be found in the official protocol docs.
This protocol command is embedded in the following convenient method: execute. It is recommended to use this command instead.
Usageโ
browser.executeScript(script, args)
Parametersโ
Name | Type | Details |
---|---|---|
script | string | a string, the Javascript function body you want executed |
args | string, object, number, boolean, null, undefined[] | an array of JSON values which will be deserialized and passed as arguments to your function |
Exampleโ
loading...
Returnsโ
- <*>
result
: Either the return value of your script, the fulfillment of the Promise returned by your script, or the error which was the reason for your script's returned Promise's rejection.
executeAsyncScriptโ
The Execute Async Script command causes JavaScript to execute as an anonymous function. Unlike the Execute Script command, the result of the function is ignored. Instead an additional argument is provided as the final argument to the function. This is a function that, when called, returns its first argument as the response.
WebDriver Protocol command. More details can be found in the official protocol docs.
This protocol command is embedded in the following convenient method: executeAsync. It is recommended to use this command instead.
Usageโ
browser.executeAsyncScript(script, args)
Parametersโ
Name | Type | Details |
---|---|---|
script | string | a string, the Javascript function body you want executed |
args | string, object, number, boolean, null, undefined[] | an array of JSON values which will be deserialized and passed as arguments to your function |
Exampleโ
loading...
Returnsโ
- <*>
result
: Either the return value of your script, the fulfillment of the Promise returned by your script, or the error which was the reason for your script's returned Promise's rejection.
getAllCookiesโ
The Get All Cookies command returns all cookies associated with the address of the current browsing contextโs active document.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.getAllCookies()
Exampleโ
loading...
Returnsโ
- <Object[]>
cookies
: A list of serialized cookies. Each serialized cookie has a number of optional fields which may or may not be returned in addition toname
andvalue
.
addCookieโ
The Add Cookie command adds a single cookie to the cookie store associated with the active document's address.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.addCookie(cookie)
Parametersโ
Name | Type | Details |
---|---|---|
cookie | object | A JSON object representing a cookie. It must have at least the name and value fields and could have more, including expiry-time and so on |
Exampleโ
loading...
deleteAllCookiesโ
The Delete All Cookies command allows deletion of all cookies associated with the active document's address.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.deleteAllCookies()
Exampleโ
loading...
getNamedCookieโ
The Get Named Cookie command returns the cookie with the requested name from the associated cookies in the cookie store of the current browsing context's active document. If no cookie is found, a no such cookie error is returned.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.getNamedCookie(name)
Parametersโ
Name | Type | Details |
---|---|---|
name | String | name of the cookie to retrieve |
Exampleโ
loading...
Returnsโ
- <Object>
cookie
: A serialized cookie, with name and value fields. There are a number of optional fields likepath
,domain
, andexpiry-time
which may also be present.
deleteCookieโ
The Delete Cookie command allows you to delete either a single cookie by parameter name, or all the cookies associated with the active document's address if name is undefined.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.deleteCookie(name)
Parametersโ
Name | Type | Details |
---|---|---|
name | String | name of the cookie to delete |
Exampleโ
loading...
performActionsโ
The Perform Actions command is used to execute complex user actions. See spec for more details.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.performActions(actions)
Parametersโ
Name | Type | Details |
---|---|---|
actions | object[] | a list of objects, each of which represents an input source and its associated actions |
releaseActionsโ
The Release Actions command is used to release all the keys and pointer buttons that are currently depressed. This causes events to be fired as if the state was released by an explicit series of actions. It also clears all the internal state of the virtual devices.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.releaseActions()
dismissAlertโ
The Dismiss Alert command dismisses a simple dialog if present, otherwise error. A request to dismiss an alert user prompt, which may not necessarily have a dismiss button, has the same effect as accepting it.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.dismissAlert()
Exampleโ
loading...
acceptAlertโ
The Accept Alert command accepts a simple dialog if present, otherwise error.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.acceptAlert()
getAlertTextโ
The Get Alert Text command returns the message of the current user prompt. If there is no current user prompt, it returns an error.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.getAlertText()
Exampleโ
loading...
Returnsโ
- <string>
alertText
: The message of the user prompt.
sendAlertTextโ
The Send Alert Text command sets the text field of a window.prompt user prompt to the given value.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.sendAlertText(text)
Parametersโ
Name | Type | Details |
---|---|---|
text | string | string to set the prompt to |
takeScreenshotโ
The Take Screenshot command takes a screenshot of the top-level browsing context's viewport.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.takeScreenshot()
Returnsโ
- <string>
screenshot
: The base64-encoded PNG image data comprising the screenshot of the initial viewport.
takeElementScreenshotโ
The Take Element Screenshot command takes a screenshot of the visible region encompassed by the bounding rectangle of an element.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.takeElementScreenshot(elementId, scroll)
Parametersโ
Name | Type | Details |
---|---|---|
elementId | String | the id of an element returned in a previous call to Find Element(s) |
scroll optional | boolean | scroll into view the element. Default: true |
Returnsโ
- <string>
screenshot
: The base64-encoded PNG image data comprising the screenshot of the visible region of an elementโs bounding rectangle after it has been scrolled into view.
getElementComputedRoleโ
Get the computed WAI-ARIA role of an element.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.getElementComputedRole(elementId)
Parametersโ
Name | Type | Details |
---|---|---|
elementId | String | the id of an element returned in a previous call to Find Element(s) |
Returnsโ
- <string>
role
: The result of computing the WAI-ARIA role of element.
getElementComputedLabelโ
Get the accessible name of the element.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.getElementComputedLabel(elementId)
Parametersโ
Name | Type | Details |
---|---|---|
elementId | String | the id of an element returned in a previous call to Find Element(s) |
Returnsโ
- <string>
label
: The result of a Accessible Name and Description Computation for the Accessible Name of the element.
setPermissionsโ
Simulates user modification of a PermissionDescriptor's permission state. Note: this feature has not landed in all browsers yet.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.setPermissions(descriptor, state, oneRealm)
Parametersโ
Name | Type | Details |
---|---|---|
descriptor | object | Each powerful feature has one or more aspects that websites can request permission to access. To describe these aspects, each feature defines a subtype of PermissionDescriptor to be its permission descriptor type. Note: this feature has not landed in all browsers yet. |
state | string | Determines whether permission is granted, denied or prompted. |
oneRealm optional | boolean | Whether or not to apply permissions to all execution contexts. |
Examplesโ
// set midi permissions
browser.setPermissions(
{ name: 'midi', sysex: true },
'granted' // can be also "denied" or "prompt"
);
// set clipboard permissions
browser.setPermissions({ name: 'clipboard-read' }, 'granted');
// now you can read the clipboard via, e.g.
const clipboardText = await browser.execute(() => navigator.clipboard.readText());
generateTestReportโ
Generates a report for testing. Extension for Reporting API. Note: this feature has not landed in all browsers yet.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.generateTestReport(message, group)
Parametersโ
Name | Type | Details |
---|---|---|
message | string | Message to be displayed in the report. |
group optional | string | Specifies the endpoint group to deliver the report to. |
createMockSensorโ
Creates a mock sensor to emulate sensors like Ambient Light Sensor. Note: this feature has not landed in all browsers yet.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.createMockSensor(mockSensorType, maxSamplingFrequency, minSamplingFrequency)
Parametersโ
Name | Type | Details |
---|---|---|
mockSensorType | string | Type of sensor API to mock, e.g. 'ambient-light' |
maxSamplingFrequency optional | number | A double representing frequency in Hz that is used to set maximum supported sampling frequency for the associated mock sensor. |
minSamplingFrequency optional | number | A double representing frequency in Hz that is used to set minimum supported sampling frequency for the associated mock sensor. |
getMockSensorโ
Retrieves information about a given type of mock sensor. Note: this feature has not landed in all browsers yet.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.getMockSensor(type)
Parametersโ
Name | Type | Details |
---|---|---|
type | String | Mock sensor type to retrieve information from. |
Returnsโ
- <object>
sensorReading
: Values of the mock sensor reading.
updateMockSensorโ
Updates the mock sensor type. Note: this feature has not landed in all browsers yet.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.updateMockSensor(type, mockSensorType, maxSamplingFrequency, minSamplingFrequency)
Parametersโ
Name | Type | Details |
---|---|---|
type | String | Mock sensor type to update information for. |
mockSensorType | string | Type of sensor API to mock, e.g. 'ambient-light' |
maxSamplingFrequency optional | number | A double representing frequency in Hz that is used to set maximum supported sampling frequency for the associated mock sensor. |
minSamplingFrequency optional | number | A double representing frequency in Hz that is used to set minimum supported sampling frequency for the associated mock sensor. |
deleteMockSensorโ
The Delete Session command closes any top-level browsing contexts associated with the current session, terminates the connection, and finally closes the current session. Note: this feature has not landed in all browsers yet.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.deleteMockSensor(type)
Parametersโ
Name | Type | Details |
---|---|---|
type | String | Mock sensor type to delete. |
setTimeZoneโ
Simulates the changing of a time zone for the purposes of testing. Note: this feature has not landed in all browsers yet.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.setTimeZone(time_zone)
Parametersโ
Name | Type | Details |
---|---|---|
time_zone | string | Name of the timezone, e.g. Asia/Tokyo |
addVirtualAuthenticatorโ
Creates a software Virtual Authenticator.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.addVirtualAuthenticator(protocol, transport, hasResidentKey, hasUserVerification, isUserConsenting, isUserVerified, extensions, uvm)
Parametersโ
Name | Type | Details |
---|---|---|
protocol optional | string | Valid values: 'ctap1/u2f', 'ctap2', 'ctap2_1'. |
transport optional | string | Valid values: 'usb', 'nfc', 'ble' or 'internal'. |
hasResidentKey optional | boolean | Valid values: true, false. |
hasUserVerification optional | boolean | Valid values: true, false. |
isUserConsenting optional | boolean | Valid values: true, false. |
isUserVerified optional | boolean | Valid values: An array containing extension identifiers. |
extensions optional | string[] | Valid values: Up to 3 User Verification Method entries. |
uvm optional | object[] |
Returnsโ
- <string>
authenticatorId
: Returns the string ID of the authenticator.
removeVirtualAuthenticatorโ
Removes a previously created Virtual Authenticator.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.removeVirtualAuthenticator(authenticatorId)
Parametersโ
Name | Type | Details |
---|---|---|
authenticatorId | String | id of authenticator |
addCredentialโ
Injects a Public Key Credential Source into an existing Virtual Authenticator.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.addCredential(authenticatorId, credentialId, isResidentCredential, rpId, privateKey, userHandle, signCount, largeBlob)
Parametersโ
Name | Type | Details |
---|---|---|
authenticatorId | String | ID of authenticator |
credentialId | string | The Credential ID encoded using Base64url Encoding. |
isResidentCredential | boolean | If set to true, a client-side discoverable credential is created. If set to false, a server-side credential is created instead. |
rpId | string | The Relying Party ID the credential is scoped to. |
privateKey | string | An asymmetric key package containing a single private key per [RFC5958], encoded using Base64url Encoding. |
userHandle | string | The userHandle associated to the credential encoded using Base64url Encoding. This property may not be defined. |
signCount | number | The initial value for a signature counter associated to the public key credential source. |
largeBlob optional | string | The large, per-credential blob associated to the public key credential source, encoded using Base64url Encoding. This property may not be defined. |
getCredentialsโ
Returns one Credential Parameters object for every Public Key Credential Source stored in a Virtual Authenticator, regardless of whether they were stored using Add Credential or navigator.credentials.create()
.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.getCredentials(authenticatorId)
Parametersโ
Name | Type | Details |
---|---|---|
authenticatorId | String | id of authenticator |
Returnsโ
- <object[]>
credentials
: Returns an array of credentials.
removeAllCredentialsโ
Removes all Public Key Credential Sources stored on a Virtual Authenticator.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.removeAllCredentials(authenticatorId)
Parametersโ
Name | Type | Details |
---|---|---|
authenticatorId | String | id of authenticator |
removeCredentialโ
Removes a Public Key Credential Source stored on a Virtual Authenticator.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.removeCredential(authenticatorId, credentialId)
Parametersโ
Name | Type | Details |
---|---|---|
authenticatorId | String | id of authenticator |
credentialId | String | id of credential |
setUserVerifiedโ
The Set User Verified extension command sets the isUserVerified property on the Virtual Authenticator.
WebDriver Protocol command. More details can be found in the official protocol docs.
Usageโ
browser.setUserVerified(authenticatorId)
Parametersโ
Name | Type | Details |
---|---|---|
authenticatorId | String | id of authenticator |