Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

Practical WebDriverIO: Learn to Automate Effectively Using WebDriverIO APIs
Practical WebDriverIO: Learn to Automate Effectively Using WebDriverIO APIs
Practical WebDriverIO: Learn to Automate Effectively Using WebDriverIO APIs
Ebook325 pages1 hour

Practical WebDriverIO: Learn to Automate Effectively Using WebDriverIO APIs

Rating: 0 out of 5 stars

()

Read preview

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.

LanguageEnglish
PublisherApress
Release dateMar 9, 2021
ISBN9781484266618
Practical WebDriverIO: Learn to Automate Effectively Using WebDriverIO APIs

Related to Practical WebDriverIO

Related ebooks

Internet & Web For You

View More

Related articles

Reviews for Practical WebDriverIO

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    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.jpg

    Figure 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.jpg

    Figure 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.jpg

    Figure 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.jpg

    Figure 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.jpg

    Figure 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

    Enjoying the preview?
    Page 1 of 1