title: Protractor conditional testing
body: <p>I am attempting to run a suite of tests, and one of the tests relies on whether an element is displayed on the page. The element in question is pagination in a table.</p>
  
  <p>The table is always present, but the pagination is only displayed if the record count is over 20. I am attempting to test the deletion of the last record in the table and so I have either delete the last record, OR click the 'last' button in the pagination, and then delete the final record.</p>
  
  <p>I have attempted to implement the following <a href="https://stackoverflow.com/questions/27947094/how-to-create-a-condition-in-protractor-for-when-an-element-exists-or-not">SO answer</a>, see below code:</p>
  
  <pre><code>it('should test the deletion of a record against whether pagination exists or not', function() {
      element(by.css('.pagination')).isDisplayed().then(function(present) {
          if(present) {
              // Click last button and perform delete on last record
          } else {
              // perform delete on last record
          };
      });
  });
  </code></pre>
  
  <p>However, when running the test, Protractor is moaning that <code>No element found using locator: By.cssSelector(".pagination")</code> when the page has a record count of less than 20 and the pagination is now displayed.</p>
  
  <p>I have passing test for both instances when I know that pagination is present or not, but to keep it as DRY as possible I want to conditionally check and ensure both sets of tests are passable dependant on the record count.</p>
  
  <p>Any help would be much appreciated!</p>