title: Failed: Cannot read property 'then' of undefined (protractor)
body: <pre><code>       //get count of checked checkboxes, 
  //count must be 1 because it selected one product
                      var checkedCount = productPage.selectedProducts.count();
                      expect(checkedCount).toBe(1).then(function () {
                          browser.sleep(2222);
                          productDialogPage. createTaskButton.click();
                      });
  </code></pre>
  
  <p>this is my code. When user selects, createtaskbutton gets active.</p>
  
  <p>normally it is disabled.</p>
  
  <p>error is</p>
  
  <blockquote>
    <p>Failed: Cannot read property 'then' of undefined
      Stack:
        TypeError: Cannot read property 'then' of undefined</p>
  </blockquote>
  
  <p>when i change to this</p>
  
  <pre><code>//get count of checked checkboxes, count must 1 be because it selected one product
                  var checkedCount = productPage.selectedProducts.count();
                  expect(checkedCount).toBe(1);
                  browser.sleep(4222);
  
  
                  //click task create and expect confirm dialog to be displyed
                  productDialogPage.createTaskButton.click();
  
  
  
  same
  </code></pre>
  
  <blockquote>
    <p>Message:
        Failed: Cannot read property 'click' of undefined
      Stack:
        TypeError: Cannot read property 'click' of undefined</p>
  </blockquote>
  
  <p>it doesnot read my spec class, it goes another spec as soon as it enters.</p>
  
  <p>also for this same</p>
  
  <pre><code>            //get count of checked checkboxes, count must 1 be because it selected one product
              var checkedCount = productPage.selectedProducts.count();
              expect(checkedCount).toBe(1);
              browser.sleep(4222);
  
  
  
              browser.wait(function() {
                  return productDialogPage.createTaskButton.isPresent();
              })
  </code></pre>