Kendall Kendall - 1 year ago 323
AngularJS Question

Waiting for element by.css() in protractor

I have some code in which

triggers an event which executes an

code in my controller

ctrlr.rollDice = function(){
.... do some stuff
$scope.$broadcast('eventType', args);

code in my directive

scope.$on('eventType', function(){ element.addClass('class'); });

I am trying to wait until the event has fired and the
is executed in my protractor test using


However, I get the following error

TypeError: Cannot read property 'getWebElements' of undefined

How do I wait for the element with the class .activate to show up ??

Note that
can be any random visible element is just to set the class. Also if I were to run the project in my actual web browser....everything runs successfully.

Answer Source

Try this:

browser.wait(() => $('.activate')).isPresent() ,15000);

Or the ES5 version

browser.wait(function() {
  return $('.activate').isPresent();
}, 15000);

Note: element(by.css('.abc')) === $('.abc')

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download