This project is my first interaction with WebDriverIO. This project has sample test code for "Sauce labs demo app". I have covered the following scenarios:
- Login scenario.
- User journey to buy the product using the app.
Sauce Labs demo app can be downloaded from here
As I was learning the tool, I thought I should upload the project in github so it helps others as well who are planning to learn this tool and also it would help me in the future to refer the code.
You need to have the following installed in your machine:
- Node (Latest Version).
- npm(Latest Version).
- Install WebdriverIO using the command:
npm install -D webdriverio
. - Install WebdriverIO CLI using the command:
npm install @wdio/cli
and update the set the wdio config file using command:npx wdio config
. (Refer for more details, if you face any problem while setting up the project refer the following official link of WebdriverIO). - Setup babel for your project using the command:
npm install -D @babel/core @babel/cli @babel/preset-env @babel/register
. You will also need to setup thebabel.config.js
as below:
module.exports = {
presets: [
['@babel/preset-env', {
targets: {
node: 'lts'
}
}]
]
}
Refer Babel Setup for more details.
- Since I am also using Video Reporter for recording the video of the tests, you need to install the plugin for
Video Reporter
as well. You can do that by simply typing the command:npm install wdio-video-reporter
. Add the reporter to config: At the top of thewdio.conf.js-file
, require the library:const video = require('wdio-video-reporter');
Then add the video reporter to the configuration in thereporters
property:
reporters: [
[video, {
saveAllVideos: true, // If true, also saves videos for successful test cases
videoSlowdownMultiplier: 3, // Higher to get slower videos, lower for faster videos [Value 1-100]
}],
],
Since, this project is for mobile app, you need to set the "deviceType": "phone"
, in the capabilities
for appium section inside the wdio.config.js
.
Refer Video-Reporter Setup for more details.
-
Install
chai
for assertions using the command:npm install -D chai
. -
For running the tests, you need to type the command:
npm test
. -
I have used
Gestures.js
for performing swipe gestures, from the appium-boilerplate project.
As far as the tests are concerned, covering the login scenario is one of the basics of automation testing and many automation engineers are well versed in writing the code for it and covering it in their automated tests. However, I have seen in recent times that most of the testers struggle to write the user journeys. Though the app testing is done in isolated tests but I think its necessary to cover the user journeys in the tests so we test as per the use case the way an end-user uses the app. Hence, apart from the login scenario I have covered the following user journey as sample tests in this project. Details are as follows:
- Login in the app.
- Click on a product - "Sauce Labs Backpack".
- Scroll the page to "Add to Cart" button and click on it.
- Get the Product name, Product description and Price of the product and check it with the test data.
- Go to "Cart" on right top of the screen and click on it.
- Check Product name, Product description and Price.
- Click on "Checkout" button.
- Enter "First Name", "Last Name" and "Postal code".
- Click on "Continue" button.
- Check Product name, Product description and Price.
- Check Item Total, Tax and Total Amount.
- Click on Finish.
- Check Order completion Title: "Thank you for you order".
- Check Order text: "Your Order has been dispatched, and will arrive just as fast as the pony can get there!".
- Discuss your queries by writing to me @ mohammadfaisalkhatri@gmail.com
- Connect me at LinkedIn or Twitter
- Spread the word with your network.
- Star the project to make the project popular.