https://github.com/react-native-windows/webdriver
webdriverio workaround for winappdriver
https://github.com/react-native-windows/webdriver
Last synced: 11 months ago
JSON representation
webdriverio workaround for winappdriver
- Host: GitHub
- URL: https://github.com/react-native-windows/webdriver
- Owner: react-native-windows
- Created: 2019-08-28T21:43:00.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-08-28T21:43:48.000Z (over 6 years ago)
- Last Synced: 2025-01-16T07:33:41.799Z (about 1 year ago)
- Language: JavaScript
- Size: 41 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
WebDriver
=========
> A lightweight, non-opinionated implementation of the [WebDriver specification](https://w3c.github.io/webdriver/webdriver-spec.html) including mobile commands supported by [Appium](http://appium.io/)
There are [tons](https://github.com/christian-bromann/awesome-selenium#javascript) of Selenium and WebDriver binding implementations in the Node.js world. Every one of them have an opinionated API and recommended way to use. This binding is the most non-opinionated you will find as it just represents the [WebDriver specification](https://w3c.github.io/webdriver/webdriver-spec.html) and doesn't come with any extra or higher level abstraction. It is lightweight and comes with support for the [WebDriver specification](https://w3c.github.io/webdriver/webdriver-spec.html) and Appiums [Mobile JSONWire Protocol](https://github.com/appium/appium-base-driver/blob/master/docs/mjsonwp/protocol-methods.md).
## Example
The following example demonstrates a simple Google Search scenario:
```js
import WebDriver from 'webdriver'
;(async () => {
const client = await WebDriver.newSession({
path: '/',
capabilities: { browserName: 'firefox' }
})
await client.navigateTo('https://www.google.com/ncr')
const searchInput = await client.findElement('css selector', '#lst-ib')
await client.elementSendKeys(searchInput['element-6066-11e4-a52e-4f735466cecf'], 'WebDriver')
const searchBtn = await client.findElement('css selector', 'input[value="Google Search"]')
await client.elementClick(searchBtn['element-6066-11e4-a52e-4f735466cecf'])
console.log(await client.getTitle()) // outputs "WebDriver - Google Search"
await client.deleteSession()
})()
```
# Configuration
To create a WebDriver session call the `newSession` method on the `WebDriver` class and pass in your configurations:
```js
import WebDriver from 'webdriver'
const client = await WebDriver.newSession(options)
```
The following options are available:
### capabilities
Defines the [capabilities](https://w3c.github.io/webdriver/webdriver-spec.html#capabilities) you want to run in your Selenium session.
Type: `Object`
Required: `true`
### logLevel
Level of logging verbosity.
Type: `String`
Default: *info*
Options: *trace* | *debug* | *info* | *warn* | *error* | *silent*
### protocol
Protocol to use when communicating with the Selenium standalone server (or driver).
Type: `String`
Default: *http*
Options: *http* | *https*
### hostname
Host of your WebDriver server.
Type: `String`
Default: *localhost*
### port
Port your WebDriver server is on.
Type: `Number`
Default: *4444*
### path
Path to WebDriver server.
Type: `String`
Default: */wd/hub*
### baseUrl
Shorten `url` command calls by setting a base url.
Type: `String`
Default: *null*
### connectionRetryTimeout
Timeout for any request to the Selenium server.
Type: `Number`
Default: *90000*
### connectionRetryCount
Count of request retries to the Selenium server.
Type: `Number`
Default: *2*