title: Use element by css to check if element exists in Protractor
body: <p>In a protractor end to end test, I want to check if an element exist using element(by.css(...)), my code:</p>
  
  <pre><code>var myElement = element(by.css('.elementClass'));
  expect(myElement).toBeUndefined;
  </code></pre>
  
  <p>This test fails, it says:</p>
  
  <pre><code>    Expected { locator_ : { using : 'css selector', value : 'div[ng-switch-
      when="resultNav"]' }, parentElementFinder_ : null, opt_actionResult_ :
      undefined, opt_index_ : undefined, click : Function, sendKeys : Function, 
  getTagName : Function, getCssValue : Function, getAttribute : Function, getText
   : Function, getSize : Function, getLocation : Function, isEnabled : Function, 
  isSelected : Function, submit : Function, clear : Function, isDisplayed : 
  Function, getOuterHtml : Function, getInnerHtml : Function, toWireValue : 
  Function } to be undefined.
  </code></pre>
  
  <p>After that I tried to use a promise:</p>
  
  <pre><code>element(by.css('.elementClass')).then( functtion(data) {
      expect(data.getText()).toBeUndefined();
  });
  </code></pre>
  
  <p>This results in an error:</p>
  
  <blockquote>
    <p>Error: No element found using locator By.CssSelector(...)</p>
  </blockquote>
  
  <p>Yes, I know that no element will be found, but how can I create a working test using element(<code>by.css(...)</code>)?</p>
  
  <p>Does anyone know how to achieve this? or is <code>element(by.css())</code> not the method to use here?</p>