- Create a folder for the project
mkdir WebDriverIO-Test
cd WebDriverIO-Test
2. Initialize the project using below command. This will create the package.json file. The -y flag configures package.json with the default values rather than asking us any questions.
npm init –y
- Install WebDriver.io by using the command:
npm install --save-dev webdriverio
- Install Selenium-Standalone server. It will allow executing a script through the web browser
npm install -g selenium-standalone
selenium-standalone install
- Start Selenium Webdriver
selenium-standalone start
- Create a file with required test steps (say test.js)
7. Run the file using node.js
node test.js
- Running using test runner:
WebDriverIO has its own test runner that is compatible with frameworks such as Mocha, Jasmine or Cucumber. Here are the steps to run the test using WebDriverIO runner:
8.1 Create a config file to run WebdriverIO with the test runner; The config file can be created by running a built-in configuration utility:
./node_modules/.bin/wdio config
8.2 Run the test using wdio config file
./node_modules/.bin/wdio wdio.conf.js
References:
http://webdriver.io/guide.html
https://buddy.works/guides/how-write-selenium-tests-in-nodejs-with-webdriver