Protractor: waiting before clicking

If you have been working with protractor, you may have come up with common issue of waits. Protractor should have this built in, but it doesn’t always get it right. So after attempting several different approaches, with partial successes, the code below (appears) to do a solid job. This example is in context of cucumberjs framework, but not dependant on it.

this.Given(/^I click the (.*) (button|filter|radio|tab|checkbox|link|icon|record|person|asset|accordion)$/, function (buttonName, buttonType, callback) {
var elm = element(by.css('#button_id'));
var EC = protractor.ExpectedConditions;
var isClickable = EC.elementToBeClickable(elm);
browser.wait(isClickable, 20000);;

No Comments

You can leave the first : )