Practical WebDriverIO: Learn to Automate Effectively Using WebDriverIO APIs
()
About this ebook
Learn how to quickly set up the test automation tool WebdriverIO, one of the major Node.js-based test frameworks. Software testing is here to stay, and an integral part of this is test automation. Dive into the amazing possibilities that WebDriverIO offers to automate browser interactions for a user of any web application.
You will learn to automate a vast range of actions that a user takes to interact with the browser. From a simple click to more complex user actions such as frame switches, selecting from drop-downs, and file downloads using WebDriverIO APIs. You will also learn about assertions, timeouts, waits, parallel testing frameworks, and the general pros and cons of WebDriverIO.
With over 150 working code samples demonstrating various test scenarios that you require in your day-to-day automation testing, this book is your practical handbook to WebDriverIO.
What You'll Learn
- Set up and install WebdriverIO efficiently
- Run parallel execution using WebdriverIO
- Review the pros, cons and challenges you may face with WebdriverIO
- Ensure optimum usage and avoid common mistakes
Who This Book Is For
This book is ideal for test engineers who have a basic understanding of test automation with Selenium, developers who want to implement this testing tool for internal testing, Test Managers/IT Project Managers who want to get some general understanding of this tool and its advantage, and students who want to pursue career in test automation.
Related to Practical WebDriverIO
Related ebooks
Practical Oracle JET: Developing Enterprise Applications in JavaScript Rating: 0 out of 5 stars0 ratingsBeginning Machine Learning in the Browser: Quick-start Guide to Gait Analysis with JavaScript and TensorFlow.js Rating: 0 out of 5 stars0 ratingsThe Protractor Handbook: Understanding and Implementing the Tool Effectively Rating: 0 out of 5 stars0 ratingsSelenium with C#: Learn how to write effective test scripts for web applications using Selenium with C# (English Edition) Rating: 0 out of 5 stars0 ratingsProgressive Web Apps with Angular: Create Responsive, Fast and Reliable PWAs Using Angular Rating: 0 out of 5 stars0 ratingsMCTS: Microsoft Silverlight 4 Development (70-506) Certification Guide Rating: 0 out of 5 stars0 ratingsMastering SoapUI Rating: 0 out of 5 stars0 ratingsBeginning Laravel: Build Websites with Laravel 5.8 Rating: 0 out of 5 stars0 ratingsPractical Svelte: Create Performant Applications with the Svelte Component Framework Rating: 0 out of 5 stars0 ratingsVisual Studio Condensed: For Visual Studio 2013 Express, Professional, Premium and Ultimate Editions Rating: 0 out of 5 stars0 ratingsBuilding Mobile Applications Using Kendo UI Mobile and ASP.NET Web API Rating: 0 out of 5 stars0 ratingsBuilding React Apps with Server-Side Rendering: Use React, Redux, and Next to Build Full Server-Side Rendering Applications Rating: 0 out of 5 stars0 ratingsPractical ASP.NET Web API Rating: 0 out of 5 stars0 ratingsGetting to Know Vue.js: Learn to Build Single Page Applications in Vue from Scratch Rating: 0 out of 5 stars0 ratingsBuilding Progressive Web Applications with Vue.js: Reliable, Fast, and Engaging Apps with Vue.js Rating: 0 out of 5 stars0 ratingsjQuery UI 1.7: The User Interface Library for jQuery Rating: 0 out of 5 stars0 ratingsPro ASP.NET MVC 5 Rating: 3 out of 5 stars3/5Mastering Snowflake Platform: Generate, fetch, and automate Snowflake data as a skilled data practitioner (English Edition) Rating: 0 out of 5 stars0 ratingsNext.js Cookbook: Learn how to build scalable and high-performance apps from scratch (English Edition) Rating: 0 out of 5 stars0 ratingsReact and Libraries: Your Complete Guide to the React Ecosystem Rating: 0 out of 5 stars0 ratingsSelenium with Java – A Beginner’s Guide: Web Browser Automation for Testing using Selenium with Java Rating: 0 out of 5 stars0 ratingsBeginning SVG: A Practical Introduction to SVG using Real-World Examples Rating: 0 out of 5 stars0 ratingsPython Testing with Selenium: Learn to Implement Different Testing Techniques Using the Selenium WebDriver Rating: 0 out of 5 stars0 ratingsSelenium Framework Design in Keyword-Driven Testing: Automate Your Test Using Selenium and Appium Rating: 0 out of 5 stars0 ratingsLearn Java for Web Development: Modern Java Web Development Rating: 0 out of 5 stars0 ratingsJumpstart UIKit: Learn to Build Enterprise-Level, Feature-Rich Websites that Work Elegantly with Minimum Fuss Rating: 0 out of 5 stars0 ratingsIntroducing Play Framework: Java Web Application Development Rating: 0 out of 5 stars0 ratingsBeginning Azure Functions: Building Scalable and Serverless Apps Rating: 0 out of 5 stars0 ratings
Internet & Web For You
Podcasting For Dummies Rating: 4 out of 5 stars4/5No Place to Hide: Edward Snowden, the NSA, and the U.S. Surveillance State Rating: 4 out of 5 stars4/5Social Engineering: The Science of Human Hacking Rating: 3 out of 5 stars3/5Coding For Dummies Rating: 5 out of 5 stars5/5Six Figure Blogging Blueprint Rating: 5 out of 5 stars5/5How to Be Invisible: Protect Your Home, Your Children, Your Assets, and Your Life Rating: 4 out of 5 stars4/5The Hacker Crackdown: Law and Disorder on the Electronic Frontier Rating: 4 out of 5 stars4/5How to Disappear and Live Off the Grid: A CIA Insider's Guide Rating: 0 out of 5 stars0 ratingsCoding All-in-One For Dummies Rating: 4 out of 5 stars4/5How To Start A Profitable Authority Blog In Under One Hour Rating: 5 out of 5 stars5/5Wireless Hacking 101 Rating: 4 out of 5 stars4/5Mike Meyers' CompTIA Security+ Certification Guide, Third Edition (Exam SY0-601) Rating: 5 out of 5 stars5/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5Get Rich or Lie Trying: Ambition and Deceit in the New Influencer Economy Rating: 0 out of 5 stars0 ratingsThe Beginner's Affiliate Marketing Blueprint Rating: 4 out of 5 stars4/5From Nothing Rating: 5 out of 5 stars5/5The Gothic Novel Collection Rating: 5 out of 5 stars5/5Tor and the Dark Art of Anonymity Rating: 5 out of 5 stars5/5Everybody Lies: Big Data, New Data, and What the Internet Can Tell Us About Who We Really Are Rating: 4 out of 5 stars4/5The Logo Brainstorm Book: A Comprehensive Guide for Exploring Design Directions Rating: 4 out of 5 stars4/5How to Build a Website Rating: 4 out of 5 stars4/5200+ Ways to Protect Your Privacy: Simple Ways to Prevent Hacks and Protect Your Privacy--On and Offline Rating: 0 out of 5 stars0 ratingsStop Asking Questions: How to Lead High-Impact Interviews and Learn Anything from Anyone Rating: 5 out of 5 stars5/5Wordpress for Beginners: The Easy Step-by-Step Guide to Creating a Website with WordPress Rating: 5 out of 5 stars5/5Cybersecurity For Dummies Rating: 4 out of 5 stars4/5
Reviews for Practical WebDriverIO
0 ratings0 reviews
Book preview
Practical WebDriverIO - Shashank Shukla
© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2021
S. ShuklaPractical WebDriverIOhttps://doi.org/10.1007/978-1-4842-6661-8_1
1. Getting Started
Shashank Shukla¹
(1)
Mandla, India
If you’re interested in browser automation through Node.js and understanding the various methods that can be employed to effectively automate user actions on your web site, this book is for you. WebdriverIO is a fast-growing automation tool that is hard to ignore as Node.js/JavaScript technologies assert their dominance in front-end and back-end web development.
This chapter briefly introduces WebdriverIO. You learn how to install it and quickly get to a point where you can start hands-on work. The chapter also discusses the following.
Why WebdriverIO is gaining popularity among a new generation of test engineers
How to run a test in 15 minutes
Steps to take if the installation fails
Demo web sites to practice test automation
Introduction
WebdriverIO is an independent and customized implementation of WebDriverJS (Selenium WebDriver) created by Christian Bromann. WebDriverJS is the official JavaScript implementation of Selenium API, packaged as ‘selenium-webdriver’ in npm, which runs on Node.js. WebdriverIO abstracts the lengthy syntax and complex asynchronous promise management of JavaScript and presents the user with easy-to-read action commands. It makes every test step synchronous, meaning the user doesn’t have to worry about any missed steps in the test code. It is very flexible, allowing users to choose assertion libraries, reporting tools, and various other components of the framework.
WebdriverIO is packaged and installed through npm and runs on Node.js, which is a JavaScript run-time environment that allows you to run JavaScript outside your browser. It can run on macOS, Linux, and Windows.
The principal reason WebdriverIO is gaining traction is that it is open source. If you have experience working with other JavaScript frameworks, you can start using this tool in no time. Figure 1-1 shows its number of downloads over the past few years, depicting its growing popularity.
../images/505463_1_En_1_Chapter/505463_1_En_1_Fig1_HTML.jpgFigure 1-1
The growing popularity of WebdriverIO (from www.npmtrends.com)
Installation
The WebdriverIO installation process is very easy. This book explains installation in the Windows 10 operating system. You need an active Internet connection and enough space on your machine to accommodate the setup.
Prerequisites
This section describes the basic tools required for a barebones WebdriverIO project setup.
Node.js
The official Node.js download page is at https://nodejs.org/en/download/. You can download the LTS (latest stable version) or the current version with the latest Node.js features. It is strongly advised to download the LTS version so that you can avoid unforeseen errors due to experimental features in the package. If you are using Node.js for the first time, it is advisable to download to the location suggested by your operating system. This applies to all the tools I recommend you install in this book. I have used Node.js version 12.16.3 (https://nodejs.org/en/blog/release/v12.16.3/) in this book. I recommend you use the same to avoid any errors due to version mismatch.
VS Code
In the JavaScript universe, VS Code is a widely used, freely available code editor. It provides good integration and support with WebdriverIO for our test development. It is frequently updated with new features to make a developer’s life easy. I use version 1.49 in this book. You are free to use the latest available version because it does not impact your execution (https://code.visualstudio.com/download).
Chrome
WebdriverIO provides flexibility to use a wide variety of browsers. Chrome (www.google.com/chrome) is used in this book because it is most convenient. Specifically, this book uses Chrome version 87.
Note that if you are using the latest version of Node.js, you might be asked to install Python or JDK as part of the installation process. I recommend installing the versions used in this book.
Installation process
Once you get these applications installed, create a folder named WebdriverIO_0709 or any name of your choosing, and open that folder via VS Code by right-clicking it, as depicted in Figure 1-2.
../images/505463_1_En_1_Chapter/505463_1_En_1_Fig2_HTML.jpgFigure 1-2
VS Code options when right-clicked
You can check the Node.js installation and version by opening your command prompt and typing node -v, as shown in Figure 1-3. This confirms that Node.js is installed in your system.
../images/505463_1_En_1_Chapter/505463_1_En_1_Fig3_HTML.jpgFigure 1-3
Checking Node.js version in command prompt
Once the VS Code is launched, click the Terminal option in the VS Code menu bar, and click New Terminal, as shown in Figure 1-4. The terminal is the command prompt embedded in the VS Code.
../images/505463_1_En_1_Chapter/505463_1_En_1_Fig4_HTML.jpgFigure 1-4
VS Click the New Terminal option
In the newly opened terminal, type the following command to initiate a node project. It creates a package.json file that manages all your project dependencies, as shown in Figure 1-5.
npm init -y
../images/505463_1_En_1_Chapter/505463_1_En_1_Fig5_HTML.jpgFigure 1-5
Default package.json file created
Use the following command to install WebdriverIO and its test runner, which enables you to start testing.
npm install @wdio/cli@6.8.0 --save-dev
To understand what this command does, you need to know what npm is. The node package manager can be compared to Google Play Store. Similar to downloading apps from Play Store, you can get any package developed and published by any Node.js programmer included in your Node.js application. The command calls WDIO CLI via npm, and using the @ symbol, it specifies the 6.8.0 version of the package. It needs to be saved to a local repository as a dev dependency, as shown in Figure 1-6. If you want to access it across any project on your Windows machine, provide the –g parameter and install it globally. WDIO CLI comprises other components, which we will see