UNPKG

2.08 kBMarkdownView Raw
1WebdriverIO
2===========
3
4> Next-gen browser and mobile automation test framework for Node.js
5
6This package provides and easy to manage API and a lot of syntactical sugar on top of the WebDriver specification. You can use WebdriverIO as a standalone package or via a testrunner using [`@wdio/cli`](https://webdriver.io/docs/clioptions.html). WebdriverIO allows to run tests locally using the WebDriver or Chrome DevTools protocol as well as remote user agents using cloud providers like [Sauce Labs](https://saucelabs.com/).
7
8## Installation
9
10You can install WebdriverIO via NPM:
11
12```sh
13$ npm install webdriverio
14```
15
16## Usage
17
18WebdriverIO by default uses Puppeteer to automate a browser like Chrome, Firefox or Chromium Edge. So if you have these installs the following script should start a browser for you and get the title of the page:
19
20```js
21import { remote } from 'webdriverio'
22
23let browser
24
25;(async () => {
26 browser = await remote({
27 capabilities: { browserName: 'chrome' }
28 })
29
30 await browser.navigateTo('https://www.google.com/ncr')
31
32 const searchInput = await browser.$('#lst-ib')
33 await searchInput.setValue('WebdriverIO')
34
35 const searchBtn = await browser.$('input[value="Google Search"]')
36 await searchBtn.click()
37
38 console.log(await browser.getTitle()) // outputs "WebdriverIO - Google Search"
39
40 await browser.deleteSession()
41})().catch((err) => {
42 console.error(err)
43 return browser.deleteSession()
44})
45```
46
47See the raw [protocol example](https://www.npmjs.com/package/webdriver#example) using the `webdriver` package to get a glance on the differences.
48
49For more information on [options](https://webdriver.io/docs/options.html#webdriver-options), [multiremote usage](https://webdriver.io/docs/multiremote.html) or integration into [cloud services](https://webdriver.io/docs/cloudservices.html) please check out the [docs](https://webdriver.io/docs/gettingstarted.html). If you want to use WebdriverIO for testing purposes, it is recommended to use the [WebdriverIO Testrunner](https://webdriver.io/docs/clioptions.html).