JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q63365F
  • License MIT

W3C WebDriver client

Package Exports

  • w3c-webdriver

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (w3c-webdriver) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

WebDriver client for JavaScript

npm version Build Status All Contributors Dependency Status semantic-release

NPM

This package provides JavaScript bindings that conform to the W3C WebDriver standard, which specifies a remote control protocol for web browsers.

🚧 Work in progress...

Method URI Template Command Implementation
POST /session New Session
DELETE /session/{session id} Delete Session
GET /status Status
GET /session/{session id}/timeouts Get Timeouts
POST /session/{session id}/timeouts Set Timeouts
POST /session/{session id}/url Go
GET /session/{session id}/url Get Current URL
POST /session/{session id}/back Back
POST /session/{session id}/forward Forward
POST /session/{session id}/refresh Refresh
GET /session/{session id}/title Get Title
GET /session/{session id}/window Get Window Handle
DELETE /session/{session id}/window Close Window
POST /session/{session id}/window Switch To Window
GET /session/{session id}/window/handles Get Window Handles
POST /session/{session id}/frame Switch To Frame
POST /session/{session id}/frame/parent Switch To Parent Frame
GET /session/{session id}/window/rect Get Window Rect
POST /session/{session id}/window/rect Set Window Rect
POST /session/{session id}/window/maximize Maximize Window
POST /session/{session id}/window/minimize Minimize Window
POST /session/{session id}/window/fullscreen Fullscreen Window
GET /session/{session id}/element/active Get Active Element
POST /session/{session id}/element Find Element
POST /session/{session id}/elements Find Elements
POST /session/{session id}/element/{element id}/element Find Element From Element
POST /session/{session id}/element/{element id}/elements Find Elements From Element
GET /session/{session id}/element/{element id}/selected Is Element Selected
GET /session/{session id}/element/{element id}/attribute/{name} Get Element Attribute
GET /session/{session id}/element/{element id}/property/{name} Get Element Property
GET /session/{session id}/element/{element id}/css/{property name} Get Element CSS Value
GET /session/{session id}/element/{element id}/text Get Element Text
GET /session/{session id}/element/{element id}/name Get Element Tag Name
GET /session/{session id}/element/{element id}/rect Get Element Rect
GET /session/{session id}/element/{element id}/enabled Is Element Enabled
POST /session/{session id}/element/{element id}/click Element Click
POST /session/{session id}/element/{element id}/clear Element Clear
POST /session/{session id}/element/{element id}/value Element Send Keys
GET /session/{session id}/source Get Page Source
POST /session/{session id}/execute/sync Execute Script
POST /session/{session id}/execute/async Execute Async Script
GET /session/{session id}/cookie Get All Cookies
GET /session/{session id}/cookie/{name} Get Named Cookie
POST /session/{session id}/cookie Add Cookie
DELETE /session/{session id}/cookie/{name} Delete Cookie
DELETE /session/{session id)/cookie Delete All Cookies
POST /session/{session id}/actions Perform Actions
DELETE /session/{session id}/actions Release Actions
POST /session/{session id}/alert/dismiss Dismiss Alert
POST /session/{session id}/alert/accept Accept Alert
GET /session/{session id}/alert/text Get Alert Text
POST /session/{session id}/alert/text Send Alert Text
GET /session/{session id}/screenshot Take Screenshot
GET /session/{session id}/element/{element id}/screenshot Take Element Screenshot

API

newSession

This function creates a new WebDriver session.

Parameters

  • url string WebDriver server URL
  • options object configuration object for creating the session

Examples

const session = await webdriver.newSession('http://localhost:4444', {
    desiredCapabilities: {
        browserName: 'Chrome'
    }
});

Returns Promise<Session> session

Session

This object represents a WebDriver session.

Type: Object

Properties

Session.delete

Delete the session.

Examples

await session.delete();

Returns Promise

Session.go

Navigate to a new URL.

Parameters

  • targetUrl string The URL to navigate to.

Examples

await session.go('http://localhost:8087');

Returns Promise

Session.getTitle

Get the current page title.

Examples

const title = await session.getTitle();

Returns Promise<string> The current page title.

Session.findElement

Search for an element on the page, starting from the document root.

Parameters

  • strategy string Locator strategy ("css selector", "link text", "partial link text", "tag name", "xpath").
  • selector string Selector string.

Examples

const element = await session.findElement('css', 'h2');

Returns Promise<Element>

Element

This object represents a WebDriver element.

Type: Object

Properties

Element.sendKeys

Send a sequence of key strokes to an element.

Parameters

  • text string The sequence of keys to type.

Examples

const input = await session.findElement('css', '[name="first-name"]');
await a.sendKeys('Hello World');

Returns Promise

Element.click

Click on an element.

Examples

const submitButton = await session.findElement('css', 'button[type="submit"]');
await submitButton.click();

Returns Promise

Element.getText

Returns the visible text for the element.

Examples

const result = await session.findElement('css', '#result');
const text = await result.getText();

Returns Promise<string> Visible text for the element.

Element.getCss

Returns the computed value of the given CSS property for the element.

Parameters

  • propertyName string CSS property.

Examples

const button = await session.findElement('css', '#red-button');
const backgroundColor = await button.getCss('background-color');

Returns Promise<string> Computed CSS property value for the element.

Contributors

Thanks goes to these wonderful people :


Igor Muchychka


Gabor Szalay


Adam Graf


Roland Orosz

This project follows the all-contributors specification. Contributions of any kind welcome!