Challenge :
- Perform an automatic acceptance test using selenium, webdriver, cucumberjs.
- Find the failed acceptance test script and take a screenshot on the page
- Save this as an artifact in the go pipeline.
It was my task for this day. I did all this by writing a script test, setting up selenium, going through pipelines and everything else.
The only problem - I could not figure out how to find the script for the failed script and take a screenshot on the page.
Problem Details : I have the following code posted in my step definitions that runs for each step of the script
var commonWrapper = function commonWrapper() {
this.World = require('../support/world').World;
this.Before(function (next) {
this.initBrowser(next);
});
this.After(function (next) {
this.browser.quit(next);
});
this.StepResult(function (event, callback) {
var stepResult = event.getPayloadItem('stepResult');
console.log(stepResult.isFailed());
callback();
});
};
module.exports = commonWrapper;
World contains browser init methods.
and this is an example scenario that i am testing
Feature: Forgot Password
As a user of Booking My account
I want to reset my password
So that I can login to my account when I forget my password
Scenario: On unsuccessful entering invalid email id
Given I am on forgot password page
When I enter invalid email "invalidemail-someDomain.com"
And click submit button
Then I should see validation message "Please enter a valid email."
. - scenario, after/before . , cucumberjs, . , stepResult, , . .
isFailed() . false , . alter-ego isSuccessful(), true , .
,
TDD, , , .