0
votes

I've a form with a text box and ui-select drop downs, on ng-blur event I'm calling a method to auto select the options in all the three ui-selects. When I do this using protractor e2e tests it is not waiting for the ui-selects to happen and submitting the form which is throwing exception as it is not finding the element that would be appeared only after submitting the form with all the required fields. I've tried browser.wait like this

browser.wait(()=>{
         expect(element(by.model('cntrl.selectOne')) ).toEqual('OneFirst');
         expect(element(by.model('cntrl.selectTwo')) ).toEqual('TwoFirst');
},2000)

it is throwing exception.

2

2 Answers

0
votes

Are you triggering the ng-blur event? You can try clicking on the textbox and then click someplace else. Or you can try

  • element(<selector>).trigger("blur")
  • element(<selector>).triggerHandler("blur")

In waiting, if you know what you're waiting for, use presenceOf

var EC = protractor.ExpectedConditions;
// Waits for the element with id 'abc' to be present on the dom.
browser.wait(EC.presenceOf($('#abc')), 5000);
0
votes

I've made a helper function, like this

this.waitForTimeouts = function(el, time) {
        browser.wait(function() {
            return element(by.css(el)).isPresent();
        }, time);
};

and

 e = '.md-active.md-clickable';
 this.waitForTimeouts(e, 3000);

This seems to be working for me. (quite close with what you wrote, but you are not returning the element.

Also, a simpler form of this would be:

  browser.wait(function() {
            return element(by.css('.md-active.md-clickable')).isPresent();
  }, 3000);