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
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
- See: WebDriver spec
This function creates a new WebDriver session.
Parameters
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
deleteSession.delete Delete the session.goSession.go Navigate to a new URL.getTitleSession.getTitle Get the current page title.findElementSession.findElement Search for an element on the page, starting from the document root.
Session.delete
- See: WebDriver spec
Delete the session.
Examples
await session.delete();Returns Promise
Session.go
- See: WebDriver spec
Navigate to a new URL.
Parameters
targetUrlstring The URL to navigate to.
Examples
await session.go('http://localhost:8087');Returns Promise
Session.getTitle
- See: WebDriver spec
Get the current page title.
Examples
const title = await session.getTitle();Returns Promise<string> The current page title.
Session.findElement
- See: WebDriver spec
Search for an element on the page, starting from the document root.
Parameters
strategystring Locator strategy ("css selector", "link text", "partial link text", "tag name", "xpath").selectorstring Selector string.
Examples
const element = await session.findElement('css', 'h2');Element
This object represents a WebDriver element.
Type: Object
Properties
sendKeysElement.sendKeys Send a sequence of key strokes to an element.clickElement.click Click on an element.getTextElement.getText Returns the visible text for the element.getCssElement.getCss Returns the computed value of the given CSS property for the element.
Element.sendKeys
- See: WebDriver spec
Send a sequence of key strokes to an element.
Parameters
textstring 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
- See: WebDriver spec
Click on an element.
Examples
const submitButton = await session.findElement('css', 'button[type="submit"]');
await submitButton.click();Returns Promise
Element.getText
- See: WebDriver spec
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
- See: WebDriver spec
Returns the computed value of the given CSS property for the element.
Parameters
propertyNamestring 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!
