Book description
Elevate your testing game to the next level using advanced techniques and proven strategies with this book for WebdriverIO beginners and automation pros alike
Key Features
- Improve your coding skills and empower your automation journey
- Leverage self-healing objects and adaptive frameworks for cutting-edge WebdriverIO automation
- Overcome script stability challenges and ensure robust, dependable test execution
- Purchase of the print or Kindle book includes a free PDF eBook
Book Description
This book helps you embark on a comprehensive journey to master the art of WebdriverIO automation, from installation through to advanced framework development.
You’ll start by following step-by-step instructions on installing WebdriverIO, configuring Node packages, and creating a simple test. Here you’ll gain an understanding of the mechanics while also learning to add reporting and screen captures to your test results to enhance your test case documentation. In the next set of chapters, you’ll delve into the intricacies of configuring and developing robust method wrappers, a crucial skill for supporting multiple test suites. The book goes beyond the basics, exploring testing techniques tailored for Jenkins as well as LambdaTest cloud environments. As you progress, you’ll gain a deep understanding of both TypeScript and JavaScript languages and acquire versatile coding skills.
By the end of this book, you’ll have developed the expertise to construct a sophisticated test automation framework capable of executing an entire suite of tests using WebdriverIO in either TypeScript or JavaScript, as well as excel in your test automation endeavors and deliver reliable, efficient testing solutions.
What you will learn
- Discover techniques to efficiently maintain and enhance your Page Object Model, saving time and effort
- Gain insight into diagnosing and resolving script instability issues to ensure reliable test execution
- Improve test resilience by building objects that adapt to changing element locators
- Enhance your testing productivity by learning to write effective test cases with TypeScript
- Explore strategies for comprehensive result analysis to enable data-driven decision-making
- Develop frameworks that adapt to evolving user journeys, ensuring long-term test sustainability
Who this book is for
Whether you are a novice software development engineer in test (SDET) joining your first WebdriverIO automation project building test cases in TypeScript, or a seasoned lead framework architect experienced in solutioning daily test automation challenges, this book is for you. This book will also help developers and framework architects with basic knowledge of JavaScript or TypeScript who are looking to gain expertise in functional frontend testing. A basic understanding of CSS and XPath will help you get the most out of this book.
Table of contents
- Enhanced Test Automation with WebdriverIO
- Foreword
- Contributors
- About the authors
- About the reviewers
- Preface
-
Chapter 1: The Utility Belt – Tools Every Superhero SDET Needs
- Virgin machine setup
-
Rule of thumb – the hardware resources and access rights must match the development team
- Installing Node.js and npm
- Alternate node package managers – Yarn versus npm
- Configuring the coding environment with GitHub Desktop
- GitHub and the GitHub Desktop tool
- Getting a GitHub account
- Installing GitHub Desktop
- Choosing your TypeScript development environment – Microsoft Visual Studio Code versus JetBrains Aqua
- Installing Visual Studio Code for your operating system
- X-ray vision – writing better code with Prettier, ESLint, and GitLens
- Installing Chrome extensions
- Installing WebdriverIO
- Summary
- Chapter 2: Fortress of Solitude – Configuring WebdriverIO
- Chapter 3: Cybernetic Enhancements – WebdriverIO Config and Debug Tips
- Chapter 4: Super Speed – Time-Travel Paradoxes and Broken Promises
-
Chapter 5: Alter Egos – The ClickAdv Wrapper
- Adding a helpers file
- The “Hello, World!” of test automation
- ES6 helper modules versus overriding intrinsic methods
- Who tests the SDET’s code? Sanity testing of the automation framework
- Extending our ES module helper file with a custom click method
- Why are waits difficult to implement correctly?
- Expanding the click method wrapper
- Supercharged scroll before a click event
- Expanding the click method wrapper
- The importance of metrics
- Self-healing elements
- Stubbing out methods with the “alreadyFailed” switchboard key
- Summary
-
Chapter 6: The setValue Wrapper – Entering Text and Dynamic Data Replacement
- Normalizing the element type
- Adding the setValue() method wrapper
- Is this trip really necessary?
- Coal into diamonds – replacing dynamic data tags
- Injecting versus typing text into a field
- Checking whether the field is pre-populated for speed
- Behind the mask – SetValuePassword() to keep data secure
- Putting it all together
- Summary
- Chapter 7: The Select Wrapper – Choosing Values in Lists and Comboboxes
- Chapter 8: The Assert Wrapper – the Importance of Embedded Details
- Chapter 9: The Ancient Spell Book – Building the Page Object Model
- Chapter 10: Increased Flexibility – Writing Robust Selectors and Reducing Maintenance
- Chapter 11: Echo Location – Skipping the Page Object Model
- Chapter 12: Superhero Landing – Setting Up Flexible Navigation Options
-
Chapter 13: The Multiverses – Cross-Browser Testing and Cross-Environment Testing
- Horizontal scaling – cross-browser testing
- Using built-in functionality via the wdio config file
- Using LambdaTest online to automate the browser testing grid
- Using Selenium Standalone server to locally build the testing grid
- Avoiding the rabbit hole of horizontal scaling
- Handling environment-specific logic
- The multiverse – one test, two environments
- Summary
- Chapter 14: The Time-Traveler’s Dilemma – State-Driven End to End User Journeys
-
Chapter 15: The Sentient Cape – Running Tests in a CI/CD Pipeline with Jenkins and LambdaTest
- Technical requirements
- What are Jenkins and Slack?
- Installing OpenJDK for Jenkins
- Installing Jenkins as a standalone application
- Installing Jenkins
- Creating a WebdriverIO project with Jenkins
- Installing the Jenkins plugin for LambdaTest
- Creating a freestyle project and job
- Reporting in Slack from Jenkins
- On-demand and scheduled suite runs
- Types of debugging runs with Jenkins
- CI/CD pipeline
- Summary
-
Appendix: The Ultimate Guide to TypeScript Error Messages, Causes, and Solutions
- Problem: Install default WDIO settings by passing “--yes” parameter still asks configuration questions
- Problem: Missing script “wdio”
- Problem: “node : The term ‘node’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.”
- Problem: ‘wdio’ is not recognized as an internal or external command”
- Problems:
- Problem: The \node_modules folder is not created when installed in a new WDIO project folder.
- Problem: New project install fails with empty directory.
- Problem: Tests suddenly fail to run including the \specs\test.e2e.ts. sample test.
- Problem: “WARN webdriver: Request encountered a stale element - terminating request”
- Problem: “TypeError: elem[prop] is not a function”
- Problem: Statements execute out of order
- Problem: “ERROR @wdio/runner: Error: describe expects a function argument; received [object AsyncFunction]”
- Problem: “Unsupported engine”
- Problem: JavaScript Debug Terminal skips breakpoints
- Problem: Browser launches and locks up
- Problem: “SevereServiceError: Couldn’t start Chromedriver: timeout. Please check if port [<PortNumber>] is in use”
- This is how to do it using macOS: lsof -i :<PortNumber> : kill -9 <PID>
- Problem: MODULE_NOT_FOUND
- Problem: Error: Could not execute “run” due to missing configuration, file “C:\repos\wdio\test\wdio.conf.ts” not found! Would you like to create one?
- Problem: “report does not exist” when running an Allure report
- Problem: “[P]lugin “allure” reporter, neither as wdio scoped package “@wdio/allure-reporter” nor as community package “wdio-allure-reporter”. Please make sure you have it installed!”
- Problem: TypeError: Cannot read properties of undefined (reading ‘open’)
- Problem: Cannot read properties of undefined (reading ‘setWindowSize’)
- Problem: A service failed in the ‘onPrepare’ hookSevereServiceError: Couldn’t start Chromedriver: timeout. Please check if port 9515 is in use!
- Problem: “Cannot find name ‘describe’” and underlined in red
- Problem: “Cannot find name ‘it’”
- Problem: “Cannot find name ‘expect’. Do you need to install type definitions for a test runner?” but the test still runs.
- Problem: “An import path can only end with a ‘.ts’ extension when ‘allowImportingTsExtensions’ is enabled.ts(5097)”
- Problem: browser.debug() generates “Failed to read descriptor from node connection: A device attached to the system is not functioning.”
- Problem: Element implicitly has an ‘any’ type because type ‘typeof globalThis’ has no index signature
- Problem: Cannot find type definition file for ‘jasmine’
- Problem: “Execution of 0 workers” No tests get executed.
- Problems: Cannot find name ‘browser’ and Cannot find name ‘$’
- Problem: Property ‘toBeExisting’ does not exist on type
- Problem: ERR! [Error: EACCES: permission denied (Mac OSX)
- Problem: ERROR @wdio/selenium-standalone-service: Error: not found: java
- Problem: “ECONNREFUSED 127.0.0.1:9515” a service failed in the ‘onPrepare’ hook tcp-port-used
- Problem: Error: Cannot find module ‘C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js’
- Problem: “Note: Package.json must be actual JSON, not just JavaScript”
- Problem: Protocol error (Runtime.callFunctionOn) target closed
- Problem: “unexpected token” in tsconfig.json
- Problem: “TypeError: elem[prop] is not a function”
- Problem: “ServerServiceError in “onPrepare” Cannot find package ‘chromedriver’
- Problem: Property ‘{functionName}’ does not exist on type ‘({functionType<{argName>}) => void’
- Problem “Property ‘addCommand’ does not exist on type ‘Browser’.” (macOS)
- Problem: ConfigParser: pattern ./test/specs/**/*.ts did not match any file.
- Problem: Error: Timeout - Async function did not complete within 10000ms (set by jasmine.DEFAULT_TIMEOUT_INTERVAL)
- Problem: Error: Error: Couldn’t find page handle
- Problem: This expression is not callable. Type ‘void’ has no call signatures.ts Are you missing a semicolon?
- Problem: “File is not a module”
- Problem: “Couldn’t find page handle”
- Problem: “Error: {pageName} is not defined”
- Problem: Argument of type ‘ChainablePromiseElement<Element>’ is not assignable to parameter of type ‘Element’.
- Problem: Unable to delete or modify files or folders in the WebdriverIO project
- Problem: EJSONPARSE Unexpected token in JSON while parsing Failed to parse JSON data
- Problem: A long string of gibberish garbage characters is added to the wdio.config.ts file when running in JavaScript Debug Terminal in Windows
- Yarn and Node Package Manager (npm), Node Version Manager (nvm), and Node Package Executor (npx) Shell command cheat sheet
- Reference links
- Epilogue
- Index
- Other Books You May Enjoy
Product information
- Title: Enhanced Test Automation with WebdriverIO
- Author(s):
- Release date: November 2023
- Publisher(s): Packt Publishing
- ISBN: 9781837630189
You might also like
book
Mobile Test Automation with Appium
Automate your mobile app testing About This Book How to automate testing with Appium Apply techniques …
article
Run Llama-2 Models Locally with llama.cpp
Llama is Meta’s answer to the growing demand for LLMs. Unlike its well-known technological relative, ChatGPT, …
article
Use Github Copilot for Prompt Engineering
Using GitHub Copilot can feel like magic. The tool automatically fills out entire blocks of code--but …
book
Create an Enterprise-Level Test Automation Framework with Appium: Using Spring-Boot, Gradle, Junit, ALM Integration, and Custom Reports with TDD and BDD Support
Think from a framework design perspective and move beyond straightforward coding skills. You’ll design an enterprise …