title: Waiting for element by.css() in protractor
body: <p>I have some code in which <code>$scope.$broadcast</code> triggers an event which executes an <code>element.addClass()</code></p>
  
  <p>code in my controller</p>
  
  <pre><code>ctrlr.rollDice = function(){
   .... do some stuff 
   $scope.$broadcast('eventType', args);
  }
  </code></pre>
  
  <p>code in my directive </p>
  
  <pre><code>scope.$on('eventType', function(){ element.addClass('class'); });
  </code></pre>
  
  <p>I am trying to <strong>wait</strong> until the event has fired and the <code>element.addClass</code> is executed in my protractor test using</p>
  
  <pre><code>browser.wait(element(by.css('.activate')).isPresent,15000).then(function(isPresent){
        expect(isPresent).toBe(true);
      });
  </code></pre>
  
  <p>However, I get the following error </p>
  
  <blockquote>
    <p>TypeError: Cannot read property 'getWebElements' of undefined</p>
  </blockquote>
  
  <p>How do I <strong>wait</strong> for the element with the class <em>.activate</em> to <em>show up</em> ??</p>
  
  <p>Note that <code>element</code> can be any random visible element ...it is just to set the class. Also if I were to run the project in my actual web browser....everything runs successfully. </p>