Using the protractor-cucumber-framework
, I'm trying to click a button a hundred times in one When-step. However, doing this would result in a timeout with the default 5000ms timeout value. I'd rather not change this default using:
var config = function() {
this.setDefaultTimeout(60*1000);
};
module.exports = config;
This works, but I would rather set the timeout for that single step like so:
this.When(/^I click on the "([^"]*)" button$/, {timeout: 60*1000}, function(text, callback)
{
// Click the button 100 times
var button = element(by.partialButtonText('Widget'));
for(j = 0; j < i; j++) {
button.click();
}
callback();
});
According to the cucumber-js readme this should work, but still results in:
Error: Step timed out after 5000 milliseconds
at Timer.listOnTimeout (timer.js:92:15)
Any ideas on why this doesn't work?
EDIT: It did work. However, I was using it in the wrong step. Calling click()
a hundred times doesn't take so long. It times out on the step after it:
this.Then(/^a new widget is created$/, {timeout: 60 * 1000}, function(callback) {
// Check if 100 widgets are created
});
Can anyone explain now why the long timeout is necessary in the step after all the calls to click
? Is there a more elegant way to have cucumber wait for the buttonclicks to finish?