WebdriverIO - Happy path flow



Let us create a simple happy flow to demonstrate how to create a basic WebdriverIO test −

Step 1 − Install NodeJS. The details on how to perform this installation are given in detail in the Chapter titled Getting Started with NodeJS.

Step 2 − Install NPM. The details on how to perform this installation are given in detail in the Chapter titled Installation of NPM.

Step 3 − Install VS Code. The details on how to perform this installation are given in detail in the Chapter titled VS Code Installation.

Step 4 − Create the Configuration file. The details on how to perform this installation are given in detail in the Chapter titled Configuration File generation.

Step 5 − Create a spec file. The details on how to perform this installation are given in the Chapter titled Mocha Installation

Step 6 − Add the below code within the Mocha spec file created.

// test suite name
describe('Tutorialspoint application', function(){
   //test case
   it('Happy Flow', function(){    
      // launch url
      browser.url('https://www.tutorialspoint.com/about/about_careers.htm')
      //identify element with link text then click
      $("=Team").click()
      //verify URL of next page with assertion
      expect(browser).toHaveUrlContaining('team')
   });
});

Step 7 − Run the Configuration file - wdio.conf.js file with the following command −

npx wdio run wdio.conf.js

The details on how to create a Configuration file are discussed in detail in the Chapter titled Wdio.conf.js file and Chapter titled Configuration File generation.

The following screen will appear on your computer −

Happy Path

Step 8 − On investigating further on the output, we shall see the test within the spec file testcase1.js is marked as PASSED.

The browser version and operating system on which the test has been executed, session id, name of the spec file, test suite name - Tutorialspoint Application, test case name - Happy Flow, duration of test execution, and so on, have also been captured in the console.

Advertisements