Member-only story
Capturing details and screenshots during a WebdrioverIO test
The Problem
In your project, you may want to capture specified actions of each executed test in a file. Capturing the date and time along with the name will be a good way to identify each test case for future verification. Also, part of the problem is while executing, if the test fails, then capture a screenshot as well.
A Solution
One solution is to trigger custom actions during the execution cycle. Automation tools usually support these features. The WDIO test runner allows setting hooks to be triggered at specific times of the test lifecycle. Hooks are blocks of code that can run at various points in the execution cycle. This allows custom actions like capturing the date and time along with the name before and after the test. The same hook can be used to capture screenshots if a test fails.
An Example that explains the end-to-end flow of the solution starting from webdriverIO installation.
WebdriverIO provides a single line command to create a fresh WebdriverIO project. create-wdio
works on macOS, Windows, and Linux.
% npx create-wdio ./e2e
npx
is a command-line interface (CLI) tool to install and manage dependencies hosted in the node package manager (npm
) registry. You will need a node installation to successfully run the npx
command.
% which npx% npx -v