Reputation: 666
Cucumber step definition
Then(/^Submit Button is disabled$/, function (done) {
element(by.buttonText('Search')).isEnabled().then(function (result) {
expect(result).to.equal(false);
done();
});
})
Console error:
[12:17:13] E/launcher - expected false to equal true [12:17:13] E/launcher - AssertionError: expected false to equal true at D:\Mercurial\PromotionFinder\PromotionFinder\PromotionFinder.Web\features\steps\cucumber.js:178:31 at elementArrayFinder_.then (C:\Users\abhishes\AppData\Roaming\npm\node_modules\protractor\lib\element.ts:840:22) at ManagedPromise.invokeCallback_ (C:\Users\abhishes\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1366:14) at TaskQueue.execute_ (C:\Users\abhishes\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2970:14) at TaskQueue.executeNext_ (C:\Users\abhishes\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2953:27) at asyncRun (C:\Users\abhishes\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2813:27) at C:\Users\abhishes\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:676:7 at process._tickCallback (internal/process/next_tick.js:103:7) [12:17:13] E/launcher - Process exited with error code 199
Protractor configuration
exports.config = {
// seleniumAddress: 'http://127.0.0.1:9001/',
resultJsonOutputFile: "./e2e_report/report.json",
getPageTimeout: 60000,
allScriptsTimeout: 500000,
framework: 'custom',
// path relative to the current config file
frameworkPath: require.resolve('protractor-cucumber-framework'),
capabilities: {
'browserName': 'chrome',
chromeOptions: {
args: [
'--start-maximized'
]
}
},
// Spec patterns are relative to this directory.
specs: [
'./features/*.feature'
],
baseURL: 'https://angularjs.org/',
cucumberOpts: {
require: ["./features/globals.js", './features/steps/*.js'],
tags: [],
format: 'pretty',
profile: false,
'no-source': true,
"compiler": [] //,
//format:"json:./e2e_report/report.json"
}
};
whenever assertion is failed test execution stop abruptly and no test report is generated.
I am using Protractor version - 5, cucumberjs version 2.0.0 and chai & chai-as-promised for assertion
I want information like below:
1 scenario (1 failed) 5 steps (1 failed, 3 skipped, 1 passed)
and result.json to be created so that i can see results in teamcity.
Upvotes: 0
Views: 934
Reputation: 152
You need to catch the exceptions. There are two ways to do it. Catching the exception at the return...
Then(/^Submit Button is disabled$/, function (done) {
element(by.buttonText('Search')).isEnabled().then(function (result) {
expect(result).to.equal(false);
done();
}).catch(function(err){
return;
});
});
Other is by adding callback as a parameter in the function definition.
Then(/^Submit Button is disabled$/, function (done, callback) {
element(by.buttonText('Search')).isEnabled().then(function (result) {
expect(result).to.equal(false);
done();
}).catch(function(reason) {
callback(reason);
});
});
Upvotes: 0
Reputation: 2375
I haven't yet worked with CucumberJS 2.0.0 because it is a RC version and I saw some troubles with it on the internet. 2.1.0 is a stable version, so maybe that can solve the problem.
When I look at your code I think this should do the trick.
// With callbacks
Then(/^Submit Button is disabled$/, function(done) {
var searchButton = element(by.buttonText('Search'));
return expect(searchButton.isEnabled()).to.eventually.equal(false).and.notify(done);
});
// With Promises
Then(/^Submit Button is disabled$/, function() {
var searchButton = element(by.buttonText('Search'));
return expect(searchButton.isEnabled()).to.eventually.equal(false);
});
Hope it helps
Upvotes: 1