PageRenderTime 23ms CodeModel.GetById 2ms app.highlight 17ms RepoModel.GetById 1ms app.codeStats 0ms

Markdown | 53 lines | 41 code | 12 blank | 0 comment | 0 complexity | fe267e8c2addaa338044e3b298e2543d MD5 | raw file
 1name: modes
 2category: getstarted
 3tags: guide
 4index: 3
 5title: WebdriverIO - How to use WebdriverIO
 8# How to use WebdriverIO
10WebdriverIO can be used for various purposes. It implements the Webdriver protocol API and can run browser in an automated way. The framework is designed to work in any arbitrary environment and for any kind of task. It is independent from any 3rd party frameworks and only requires Node.js to run.
12### Standalone Mode
14The probably simplest form to run WebdriverIO is in standalone mode. This has nothing to do with the Selenium server file which is usually called `selenium-server-standalone`. It basically just means that you require the `webdriverio` package in your project and use the API behind it to run your automation. Here is a simple example:
17var webdriverio = require('webdriverio');
18var options = { desiredCapabilities: { browserName: 'chrome' } };
19var client = webdriverio.remote(options);
22    .init()
23    .url('')
24    .setValue('#search_form_input_homepage', 'WebdriverIO')
25    .click('#search_button_homepage')
26    .getTitle().then(function(title) {
27        console.log('Title is: ' + title);
28        // outputs: "Title is: WebdriverIO (Software) at DuckDuckGo"
29    })
30    .end();
33Using WebdriverIO in standalone mode allows you to integrate this automation tool in your own (test) project to create a new automation library. Popular examples of that are [Chimp]( or [CodeceptJS]( You can also write plain Node scripts to scrape the World Wide Web for content or anything else where a running browser is required.
35### The WDIO Testrunner
37The main purpose of WebdriverIO though is end to end testing on big scale. We therefore implemented a test runner that helps you to build a reliable test suite that is easy to read and maintain. The test runner takes care of many problems you are usually facing when working with plain automation libraries. For one it organizes your test runs and splits up test specs so your tests can be executed with maximum concurrency. It also handles session management and provides a lot of features that help you to debug problems and find errors in your tests. Here is an same example from above written as test spec and executed by wdio:
40describe('DuckDuckGo search', function() {
41    it('searches for WebdriverIO', function() {
42        browser.url('');
43        browser.setValue('#search_form_input_homepage', 'WebdriverIO');
46        var title = browser.getTitle();
47        console.log('Title is: ' + title);
48        // outputs: "Title is: WebdriverIO (Software) at DuckDuckGo"
49    });
53The test runner is an abstraction of popular test frameworks like Mocha, Jasmine or Cucumber. Different than using the standalone mode all commands that get executed by the wdio test runner are synchronous. That means that you don't use promises anymore to handle async code. To run your tests using the wdio test runner check out the [Getting Started](/guide/testrunner/gettingstarted.html) section for more information.