Allure Report integration with WebDriver.js and Mocha
Kushan Shalindra Amarasiri
Director Quality Engineering at Social Catfish
Reporting is one of the key components of a test automation framework. It provides a detailed explanation about the test automation execution. Information such as which test cases passed and which test cases failed in a test suite, where the test failure occurred, with additional screen shots should be provided.
There are many ready to use reporting modules available which eases us of developing a reporting framework from scratch. Allure, Extent and Vigo reporting are some of these awesome reporting frameworks.
In this publication will be covering the Allure - WebDriverJS integration which is one of the first integrations that I'm going to introduce. My current framework is based on Mocha so I will be using allure-mocha library.
Following node modules should be installed with the NPM command
npm install selenium-webdriver //install webdriver.js
npm install chromedriver //install chromedriver
npm install -g mocha //install mocha
npm install mocha-allure-reporter //install mocha allure reporter
Next lets start writing our automated test scenario in Java Script.
var webdriver = require('C:/Users/lkkushan/node_modules/selenium-webdriver');
var chrome = require('C:/Users/lkkushan/node_modules/node_modules/chromedriver');
var allureReport = require('C:/Users/lkkushan/node_modules/mocha-allure-reporter');
var chai = require('C:/Users/lkkushan/node_modules/chai');
describe( 'Test Suite - Google Search' , function(){
it( 'Test Case - Google Searching', function(){
var driver = new webdriver.Builder()
.withCapabilities( { 'browserName' : 'chrome' } )
.build();
driver.get("https://www.google.com");
driver.findElement(webdriver.By.id("lst-ib")).sendKeys("webdriverjs");
driver.findElement(webdriver.By.id("hplogo")).click();
driver.findElement(webdriver.By.name("btnK")).click();
driver.findElement(webdriver.By.linkText("webdriverjs - npm")).click();
var titlePromise = driver.getTitle();
titlePromise.then(function(title){
chai.expect (driver.getTitle()).equals("webdriverjs1");
});
})
});
Execute the test successfully and you will see a folder called allure-results created in your user folder.
Now lets download the allure generator.
After downloading the allure generator place the bin path in your environment variables.
Next lets call the allure serve command specifying the location of the allure results folder, from command line.
C:\Users\lkkushan>allure serve C:\Users\lkkushan\allure-results
After generating the report, the allure dashboard will popup in your browser.
There we are allure-webdriverjs integration done. Allure reporting framework makes reporting awesome.
Software Test Manager
6 å¹´Can you to integrate selenium webdriverjs tests (in mocha-chai) with jenkins CI? Thanks.