نشرت على Nov 22, 2019
Automation Tes insights about QA for Startups using UI Automation Test report using Protractor, BDD and cucumber-html-reporter
In the feature-oriented test script development, the Test Reporting solution is feasible for the Protractor framework with cucumber integration. Let’s start the Automation Test with the framework structure.
Test script designed based on the test cases order by test scenario provided for UI Automation Test reporting. On this framework, Cucumber feature file does the control of the execution order. Just like TestNG or JUnit do. But unlike those frameworks in this solution.=
The component we are using here is an Open source tool from npm. Inc These guys are providing amazing openSource tools. Will be helpful for you in the future.
Essential JavaScript development tools that help you go to market faster and build powerful applications using modern open-source code. We are only considering this tool for Automation Test in this article.
5.0.0 • Public What does this component does, is basically creating a JSON file with the cucumber result API? To enable this you need to install
npm install cucumber-html-reporter --save-dev
The latest version of this support cucumber 3 🙂
Install cucumber-html-reporter@2.0.3 for cucumber version < Cucumber@3
Install cucumber-html-reporter@0.5.0 for cucumber version < Cucumber@2
Install cucumber-html-reporter@0.4.0 for node version <0.12
Let’s get you started. If you have already installed this component (Keep the focus on cucumber version).
1.Install package
2.Add code to the Runner class (this will create json file for you)
3.Create index.js file (to convert your json to HTML)
4.Run index.js (this will create html report in the mentioned location)
This module converts Cucumber’s JSON format to HTML reports.
In order to generate JSON formats, run the Cucumber to create the JSON format and pass the file name to the formatter as shown below,
$ cucumberjs test/features/ -f json:test/report/cucumber_report.json
Multiple formatter are also supported,----->
$ cucumberjs test/features/ -f summary -f json:test/report/cucumber_report.json
Are you using cucumber with other frameworks or running cucumber-parallel? Pass relative path of JSON file to the options as shown here
Now modify your runner class
cucumberOpts: {
require: ['src/spec/*.spec.ts'],
format: 'json:src/report/cucumber_report.json'
},
Note :Applicable if storeScreenshots=true. Relative path for directory where screenshots should be saved. E.g. the below options should store the screenshots to the <parentDirectory>/screenshots/ whereas the report would be at <parentDirectory>/report/cucumber_report.html
'keyword': 'Feature',
'name': 'Test Login in the System ',
'line': 1,
'id': 'test-login-in-the System',
'tags': [],
'uri': 'features/login.feature',
'elements': [
{
'id': 'test-login-in-the;admin-login-function-positive',
'keyword': 'Scenario',
'line': 2,
'name': 'Admin Login function Positive',
'tags': [],
'type': 'scenario',
'steps': [
{
'arguments': [],
'keyword': 'Given ',
'line': 3,
'name': 'Navigate to home',
'match': {
'location': 'src/spec/login.spec.ts:13'
},
'result': {
'status': 'passed',
'duration': 2000000
}
},
{
'arguments': [],
'keyword': 'Then ',
'line': 4,
'name': 'Admin positive Login',
'match': {
'location': 'src/spec/login.spec.ts:19'
},
'result': {
'status': 'passed',
'duration': 15156000000
}
},
{
'arguments': [],
'keyword': 'Then ',
'line': 5,
'name': 'Admin Logout',
'match': {
'location': 'src/spec/login.spec.ts:24'
},
'result': {
'status': 'passed',
'duration': 8876000000
}
},
{
'arguments': [],
'keyword': 'Then ',
'line': 6,
'name': 'Admin Negative Login',
'match': {
'location': 'src/spec/login.spec.ts:30'
},
'result': {
'status': 'passed',
'duration': 13136000000
}
},
{
'arguments': [],
'keyword': 'Then ',
'line': 7,
'name': 'Validate Error Message',
'match': {
'location': 'src/spec/login.spec.ts:35'
},
'result': {
'status': 'failed',
'duration': 1704000000,
'error_message': 'AssertionError: Error message not Validated !!\n at Login.<anonymous> (/home/aux-120/Desktop/Automation/dev2/UIAutmoation/src/pages/LoginPage.ts:53:9)\n at step (/home/aux-120/Desktop/Automation/dev2/UIAutmoation/src/pages/LoginPage.ts:32:23)\n at Object.next (/home/aux-120/Desktop/Automation/dev2/UIAutmoation/src/pages/LoginPage.ts:13:53)\n at fulfilled (/home/aux-120/Desktop/Automation/dev2/UIAutmoation/src/pages/LoginPage.ts:4:58)\n at <anonymous>\n at process._tickCallback (internal/process/next_tick.js:188:7)'
}
{
'keyword': 'After',
'hidden': true,
'match': {
'location': 'node_modules/protractor-cucumber-framework/lib/resultsCapturer.js:25'
},
'result': {
'status': 'passed',
'duration': 1000000
}
}
]
}
]
}
]
var reporter = require('cucumber-html-reporter');
var options = {
theme: 'bootstrap',
jsonFile: 'src/report/cucumber_report.json',
output: 'src/report/cucumber_report.html',
screenshotsDirectory: 'src/screenshots/',
storeScreenshots: false,
reportSuiteAsScenarios: true,
launchReport: true,
metadata: {
'App Version':'0.0.0',
'Test Environment': '[server]',
'Browser': 'Version 74.0.3729.169 (Official Build) (64-bit)',
'Platform': 'Ubuntu 18.04',
'Parallel': 'Scenarios',
'Executed': 'Remote'
}
};
reporter.generate(options);
$ node index.js
output: 'src/report/cucumber_report.html',
Reference: https://www.npmjs.com/package/cucumber-html-reporter#storescreenshots
For More Related Subjects: ZIWO API
قراءات
أحدث الأخبار
مقابلات، نصائح، دليل، أفضل الممارسات في الصناعة، وأخبار
Strategies for a Productive First Contact with Clients
Take time to focus on the First Contact with Clients, so you can adjust the customer experience (CX) strategy to provide the best service.
اقرا المزيدThe Power of WhatsApp Business with ZIWO Conversations
ZIWO Conversations is recognized as the premier WhatsApp Business Companion, elevating both customer experiences and team collaboration to a higher standard.
اقرا المزيدPause and Resume Call Recording – Benefits & Industries
agents can manually pause and resume call recordings, Once an administrator has enabled the feature, agents will see a button on the dialpad
اقرا المزيدOutbound IVR (Interactive Voice Response) – Definition, Components, Benefits & Practices
Outbound IVR feature is a contact center tool that is used to proactively distribute communications to customers with a predefined IVR menu.
اقرا المزيدHow to Become a Customer-Centric Organization
Ways to Build a customer-centric culture in your company, customer-centricity needs to be part of your philosophy, values, and mission daily.
اقرا المزيدMultilingual Contact Centers: Bridging Language Gaps
Discover how multilingual contact centers overcome language barriers to deliver outstanding assistance, thereby elevating customer experience
اقرا المزيد