Allure Report integration with WebDriver.js and Mocha

Allure Report integration with WebDriver.js and Mocha

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.

Tan vir

Software Test Manager

6 å¹´

Can you to integrate selenium webdriverjs tests (in mocha-chai) with jenkins CI? Thanks.

赞
回复

要查看或添加评论,请登录

Kushan Shalindra Amarasiri的更多文章

  • Test automation planning and contents of a test automation plan.

    Test automation planning and contents of a test automation plan.

    Test automation is an important in any software development project. It facilitates faster regression cycles, reduces…

    2 条评论
  • Considerations that should be done when starting test automation in your project or organization

    Considerations that should be done when starting test automation in your project or organization

    Today test automation is a vital part in the software testing practice. Test automation is used to expedite testing and…

  • Use of AI to shape up testing

    Use of AI to shape up testing

    Artificial Intelligence is a popular subject or topic in the IT world which shape up how we live and how we behave…

    2 条评论
  • Let's Start Test Automation with Playwright

    Let's Start Test Automation with Playwright

    Playwright is an open-source framework developed by Microsoft and released in 2020. It is relatively new to the market…

  • Things to consider when developing Test Automation Frameworks

    Things to consider when developing Test Automation Frameworks

    Test automation is a key component in the software development and testing projects. Test automation should be carried…

    6 条评论
  • Most Common Mistakes We Make In Test Automation

    Most Common Mistakes We Make In Test Automation

    Test automation makes are life easy as for a tester as well as for the entire project team. Test automation helps to…

    1 条评论
  • 100% Test Automation is it a Myth or Reality

    100% Test Automation is it a Myth or Reality

    Test automation is now an essential part of the software development project as it has proven benefits to the project…

  • Shift Left Testing and How Test Automation Helps

    Shift Left Testing and How Test Automation Helps

    Today most organizations still practice shift right testing, where we test the software requirements once its delivered…

    2 条评论
  • We talk big on Test Automation but why we fail?

    We talk big on Test Automation but why we fail?

    Test automation has been a crucial part on ensuring the quality of software delivery. Today there are large amount of…

    1 条评论
  • Mistakes by Management in Test Automation

    Mistakes by Management in Test Automation

    Test automation is an essential activity in software testing currently. There are many test automation tools used for…

    2 条评论

社区洞察

其他会员也浏览了