PageRenderTime 77ms CodeModel.GetById 42ms RepoModel.GetById 0ms app.codeStats 0ms

/node_modules/webdriverio/docs/guide/getstarted/modes.md

https://bitbucket.org/ybozkurt12/n11keytorc
Markdown | 53 lines | 41 code | 12 blank | 0 comment | 0 complexity | fe267e8c2addaa338044e3b298e2543d MD5 | raw file
Possible License(s): JSON, Unlicense, BSD-3-Clause, Apache-2.0, CC-BY-SA-3.0, MIT, 0BSD, LGPL-2.1
  1. name: modes
  2. category: getstarted
  3. tags: guide
  4. index: 3
  5. title: WebdriverIO - How to use WebdriverIO
  6. ---
  7. # How to use WebdriverIO
  8. WebdriverIO 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.
  9. ### Standalone Mode
  10. The 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:
  11. ```js
  12. var webdriverio = require('webdriverio');
  13. var options = { desiredCapabilities: { browserName: 'chrome' } };
  14. var client = webdriverio.remote(options);
  15. client
  16. .init()
  17. .url('https://duckduckgo.com/')
  18. .setValue('#search_form_input_homepage', 'WebdriverIO')
  19. .click('#search_button_homepage')
  20. .getTitle().then(function(title) {
  21. console.log('Title is: ' + title);
  22. // outputs: "Title is: WebdriverIO (Software) at DuckDuckGo"
  23. })
  24. .end();
  25. ```
  26. Using 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](https://chimp.readme.io/) or [CodeceptJS](http://codecept.io/). You can also write plain Node scripts to scrape the World Wide Web for content or anything else where a running browser is required.
  27. ### The WDIO Testrunner
  28. The 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:
  29. ```js
  30. describe('DuckDuckGo search', function() {
  31. it('searches for WebdriverIO', function() {
  32. browser.url('https://duckduckgo.com/');
  33. browser.setValue('#search_form_input_homepage', 'WebdriverIO');
  34. browser.click('#search_button_homepage');
  35. var title = browser.getTitle();
  36. console.log('Title is: ' + title);
  37. // outputs: "Title is: WebdriverIO (Software) at DuckDuckGo"
  38. });
  39. });
  40. ```
  41. The 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.