Visualizing protractor results using Elastic search and Kibana

System Requirement:

This documentation is for windows system. I am using windows 10

Steps:

Installation and visualization in Kibana:

Please refer :

Pre-requisite:

  1. we can delete the previous index by doing a DELETE request to http://localhost:9200/testresults

Now lets come to Protractor:

So from the previous article , you understand how to send data and visualize it in Elastic search

We have observed that we are just sending json data using rest API and then visualizing it in Kibana by setting x and y axis with the fields we are interested in.

so to visualize the protractor result we just have to send the result to ELastic search , this can be done using jasmine customreporter listeners .

in the protractor config file add : (do npm install axios)

onPrepare: async function() {
jasmine.getEnv().addReporter({
//adding results to an array for each spec
specDone: function(result) {
console.info(JSON.stringify(result, null, 2))
array.push(result)
},
//iterating through each result and sending it to elastic search
jasmineDone: function() {
date = new Date(Date.now())
var axios = require('axios');
array.forEach((result) => {
result.date = date
var data = JSON.stringify(result);
var config = {
method: 'post',
url: 'http://localhost:9200/testresults/protractorresults',
headers: {
'Authorization': 'Basic dGVzdDp0ZXN0MTIz',
'cache-control': 'no-cache',
'APIC-Cookie': 'apicCookie',
'Postman-Token': 'ae18aba5-b962-44d4-9a1e-5684f43318d3',
'Content-Type': 'application/json'
},
data: data
};
axios(config)
.then(function(response) {
console.log(JSON.stringify(response.data));
})
.catch(function(error) {
console.log(error);
});
})
}
})
}

This will send the results to elastic search after the test is done .

Visualized result:

  1. Goto stack management>kibana>index pattern and create new index testresults
  2. Click next and add date as time field
  3. Create new dashboard with horizontal axis as ‘date’ , vertical has ‘keyword.status’ , and breakdown by ‘keyword.status’. Set color code as status.

we have visualized keyword.status in y axis and date field in x axis

An ISTQB certified Software Test Engineer and an enthusiastic fast learner with a passion for technology. linkedin : https://www.linkedin.com/in/praveendvd

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store