Socket
Socket
Sign inDemoInstall

web-driver-io-tutorial

Package Overview
Dependencies
0
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    web-driver-io-tutorial

WebDriverIO Tutorial with working web site and examples


Version published
Weekly downloads
17
increased by240%
Maintainers
1
Install size
1.08 MB
Created
Weekly downloads
 

Changelog

Source

v1.5.0 (2017-02-20)

  • updated examples to support version >4 webdriverio
    • tutorial1.js
    • copyright1.js
    • autoComplete1.js
    • carouselExample1.js
    • cssValidation1.js
    • dataLoopExample1.js
    • dataLoopExample2.js
    • linkTextURL1.js
    • linkTextURL2.js
    • formFillSubmit1.js
    • modal1.js
    • selectbox1.js
    • debugExample1.js
    • iframe1.js
    • dropDownMenu1.js
    • formFieldValidation.js
    • restAPIExample1.js
    • screenShot1.js
    • callbackPromise.js
    • saucelabs.js
  • added examples
    • tutorial1-wdio.js
    • wdio.conf-tutorial1.js
    • copyright1-wdio.js
    • wdio-conf-copyright1.js
    • pageOjectExample1.js
    • pageobjects/web-page.js
    • pageobjects/page.js
  • removed examples that supported ES6
    • tutorial1-ES6.js
    • wdio.conf-tutorial1-ES6.js
    • copyright1-ES6.js
    • wdio.conf-copyright1-ES6.js
    • dataLoopExample2-ES6.js
    • wdio.conf-dataLoopExample2-ES6.js
  • more configuration files for wdio

Readme

Source

Web Driver IO Tutorial

Build Status

This is the README for the Web Driver IO Tutorial.

Please see my blog for a complete description of the files and much more information located at:

My Blog

The live working test site for the tutorial is located at:

Working Test Site

This project was updated to support version 4 of webdriverio

Background

I recently had an interesting challenge presented to me. I needed to introduce automated testing to a Q/A department with very little technical experience and no programming experience.

This was really two (2) separate challenges. The first was to find the technologies to use to do the automated testing. The second was actually training the Q/A department.

The project will only address the technologies used and what I learned in the process.

The technologies worked well but I really had to search for information and spent many hours figuring out issues. There doesn't seem to be much on the Internet about this. I wanted to share this information, so I wrote this project along with a web site page to test all the scripts against.

I hope you find this project useful. If you do, please let me know.

Objectives

Use Technologies That:

  • Can test web site functionality
  • Can test JavaScript functionality
  • Can be run manually from command line
  • Can be run automatically with a CI
  • Have an easy to learn language for non programmers
    • Q/A personnel with basic knowledge of HTML and JavaScript
  • Use open source software (except cloud based testing platforms)

Technologies

List of technologies I choose:

  • mocha – test framework and executes the test scripts (test runner)
  • shouldjs – expressive, readable, assertion library (test if something is true)
  • webdriverio – browser control bindings (JS language bindings to communicate with Selenium)
  • selenium – browser abstraction and running factory
  • grunt - javascript task runner (used as test runner for cloud based testing platform)
  • grunt-webdriver - grunt plugin for webdriver (uses wdio as test runner)
  • wdio - test runner
  • Browser/Mobile drivers + browsers
    • Firefox (Browser and driver)
    • Chrome (Browser and driver)
    • IE (Browser and driver)
    • Safari (Browser and driver plug-in)
    • Opera (Browser)

(Not really webdriverio related but very good information)

  • supertest - test REST APIs
  • json-server - mock REST API server
  • mongodb + promise-mongo - test database driven testing
  • node-xlsx - Excel parser & builder

Tutorial Files

FilenameDescription
tutorial1.jsTitle Test - Open page and verify title
tutorial1-wdio.js - Title Test - Open page and verify title using WDIO
linkTextURL1.jsLink Text/URL Test - Verify Link Text and URL
copyright1.jsCopyright Test - Verify Copyright Text
copyright1-wdio.jsCopyright Test - Verify Copyright Text using WDIO
formFillSubmit1.jsPopulate Form Fields and Submit
showHideVerify1.jsClick Show/Hide Button and Verify Text
dynamicBrowser.jsDynamically Invoke Different Browsers
callbackPromise.jsCompares callbacks VS promises
debugExample1.jsExample Shows Several Methods on How to Debug
formFieldValidation.jsExample of Validating Form Field Errors With Both Local Commands and Reusable Commands (commonLib.js)
common/commonLib.jsExample of Reusable Functions (library)
dataLoopExample1.jsLooping Static Data to Validate URL Link/Text
dataLoopExample2.jsLooping Static Data to Populate Form Fields
pageObjectExample1.jsExample how to use page objects
pageobjects/web-page.jsExample of page objects
linkTextURL2.jsLink Text/URL Test By Looping Through Elements
cssValidation1.jsExample how to validate several CSS properties
dropDownMenu1.jsExample how to validate dropdown menu selections
carouselExample1.jsExample how to validate image carousels
screenShot1.jsExample how to take screenshots at different browser widths
autoComplete1.jsExample how to select and validate autocomplete input field
iframe1.jsExample how to select / interact multiple iframes on a page
modal1.jsExample how to interact with a modal window (bootstrap)
selectBox1.jsExmample how to interact with selectbox
saucelabs.jsExample how to use cloud based test site (saucelabs)
gruntSauceLabs.jsExample how to use grunt + grunt-webdriver + saucelabs
restAPIExample1.jsExample how to use supertest to test REST APIs
dbDataLoopExample.jsExample how to use database (mongoDB) driven testing
excelDataLoopExample.jsExample how to use excel as a data source for test data

Configuration Files

FilenameDescription
wdio.conf-tutorial1.jsWDIO config for tutorial1-wdio.js using Firefox
wdio.conf-copyright1.jsWDIO config for copyright1-wdio.js using Firefox
wdio.conf-pObjEx1.jsWDio config for pageObjectExample1.js using Firefox
wdio.conf-gruntfile.jsWDIO config with 3 browser/OS configs against saucelabs
wdio.conf-saucelabs-dataLoopExample2.jsWDIO config file for dataLoopExample2.js on two different OS/browsers (saucelabs)
wdio.conf-dataLoopExample2.jsWDIO config file for dataLoopExample2.js on two different browsers (locally)
Gruntfile.jsExample Gruntfile with grunt-webdriver and 3 browser/OS configs
Gruntfile-dataLoopExample2.jsGruntfile for dataLoopExample2.js to run against saucelabs
Gruntfile-gruntSaucelabs.jsGruntfile for gruntSaucelabs.js to run against saucelabs

Data Files

FilenameDescription
testData1.xlsxexcel spreadsheet with test data

TEST

Create selenium directory:

$ mkdir selenium

Install Selenium Stand Alone Server:
Go to http://www.seleniumhq.org/download/
Download jar file (3.0.1 latest at this time)
Save/move into the “selenium” directory
Add "selenium" directory to PATH

Start the Selenium Stand Alone Server (terminal):

 $ java -jar selenium-server-standalone-3.0.1.jar

Firefox:
Install firefox browser, if not already installed.

Firefox driver (GeckoDriver):
Go to https://github.com/mozilla/geckodriver/releases
Download latest driver
untar

$ tar -xvf <drivername>

Save/move to "selenium" directory

$ git clone https://github.com/onewithhammer/WebDriverIOTutorial.git
$ cd WebDriverIOTutorial
$ npm install
OR 
$ sudo npm install

RUN TESTS

Run locally single test using mocha as framework and runner:

$ mocha [test-script-filename]
$ mocha tutorial1.js

Note: saucelabs.js & gruntSauceLabs.js - You will need a saucelabs account in order to set the environment variables for SAUCE_USERNAME & SAUCE_ACCESS_KEY

$ export SAUCE_USERNAME=[your saucelabs username]
$ export SAUCE_ACCESS_KEY=[your saucelabs access key]

Run grunt with default config file - Gruntfile.js using mocha as framework & wdio as runner. The config file will run a few test files against saucelabs with different OS/browser combinations.

$ grunt [task-name]
$ grunt webdriver

OR

Run grunt specifying a config file:

$ grunt --gruntfile <config-filename> [task name]

Run locally a single test using mocha as framework and wdio as the runner on 2 OS/browsers:

$ grunt --gruntfile Gruntfile-dataLoopExample2.js webdriver

Run locally single test using mocha as framework and wdio as the runner:

$ wdio [config-filename]
$ wdio wdio.conf-dataLoopExample2.js

Run on saucelabs a single test using mocha as framework and wdio as the runner on 2 OS/browsers:

$ wdio [config-filename]
$ wdio wdio.conf-saucelabs-dataLoopExample2.js

TEST REST APIs

Install json-server

$ npm install -g json-server

Start json-server first with json database file (db.json)

$ cd json-server
$ json-server db.json

see https://github.com/typicode/json-server for github project.
see http://jsonplaceholder.typicode.com/ for working demo online of json-server.

then run script

$ mocha restAPIExample1.js

Use a tool like postman to view the data before and after the script is ran.

Use it.skip() to skip specs.

Note: json-server will update the db.json file.

To restore the original file (stop server first):

cp db-bak.json db.json

USE DB TEST DATA

Install and make sure mongoDB is running locally then run script

$ mocha dbDataLoopExample.js

TO DO

  • use WDIO as the test runner - DONE
    • see wdio config files
  • show example of CI (Travis) - DONE
    • see .travis.yml file for more details
  • show more should assertion lib examples
    • show examples deepEqual()
    • show examples of property() - DONE
    • show examples of instanceOf() - DONE
  • show chai assertion lib examples
  • show examples of testing REST API - DONE
    • use custom assertions - DONE
  • show examples of screenshots - DONE
  • show example of autocomplete field - DONE
  • show example using ES6 generator - DONE
  • show example using iframe - DONE
  • show example using control characters
  • show example using modal - DONE
  • show example of selectbox - DONE
  • show example using excel as a data source - DONE
  • show example using custom reporter
  • show example using page object
  • Update examples to use old async method and V4 - NA
  • Write examples of all using sync method and V4 - IN PROGRESS

Change Log

see the CHANGELOG

License

MIT © 2015-2017 Tony Keith tony.keith@yahoo.com WEBSITE

Keywords

FAQs

Last updated on 22 Feb 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc