To generate an Allure test report with WebDriverIO, you can follow these steps:
Before you start, make sure you have the following prerequisites installed:
-
Node.js: You'll need Node.js installed on your machine.
-
WebDriverIO: Install WebDriverIO globally using npm:
npm install -g webdriverio
-
Java: You need Java installed to run Allure.
-
Install Allure: Install the Allurew dependencies using npm:
npm install @wdio/allure-reporter --save-dev
-
Allure Command Line: Install the Allure command-line tool using npm:
npm install -g allure-commandline
-
Create a new directory for your WebDriverIO project and Initialize a new Node.js project using npm:
npm init -y
-
Initialize WebDriverIO using npm:
npm init wdio .
This single command downloads the WebdriverIO CLI tool and runs a configuration wizard that helps you configure your test suite.
-
Open the
wdio.conf.js
file in your project directory. -
Customize the configuration to suit your needs. For example, you can configure the specs to point to your test files, specify the browser, and other settings. Here's a minimal example:
exports.config = { reporters: ['spec', ['allure', { outputDir: 'allure-results', disableWebdriverStepsReporting: false, disableWebdriverScreenshotsReporting: false, addConsoleLogs: false, }]], }
After writing the test case or setting up the test suite, run your spec file:
npx wdio run ./wdio.conf.js --spec <file-name>.js
After successfully running the test case, use the following command to generate the Allure Report:
allure generate allure-reports && allure open
Screen.Recording.2023-10-09.at.3.31.33.PM.mov
In the above command, allure-reports represents the outputDir specified in the configuration file.
Running the command above will generate a new report and open it on a local web server. The server typically starts at http://192.168.1.158:65524.
If you want to generate a new report after already having one, you'll need to clean the existing report. You can do this using the following command:
allure clean
This command will remove the existing Allure report data, including any previously generated reports, screenshots, logs, and other related files. Alternatively, you can manually delete the allure-report folder.
After running allure clean, you can proceed to run your tests again. This will generate a new set of report data in the allure-results directory. You can then generate a fresh Allure report based on the new data when needed.