title: check an element is either absent or does not match using protractor?
body: <p>I'm using protractor (on <em>non</em>-angular pages) and want to expect that particular warning messages are absent.</p>
  
  <p>so I need to check for presence of the element, then do a toMatch() check...</p>
  
  <p>be warned I'm expecting to answer this myself shortly - but if you're a gun protractor test writer you can help me :-)</p>
  
  <p>I need to combine these two:</p>
  
  <pre><code> // utility to test expection of an element to match a regex:
   this.expectByCssToMatch = function(css, pattern) {
     browser.driver.findElement(
       by.css(css)).getText().then(function(text) {
         expect(text).toMatch(pattern);
       });
   };
   // utility to test expection an element is missing:
   this.expectByCssToBeAbsent = function(css) {
     browser.driver.isElementPresent(
       by.css(css)).then(function(present) {
         expect(present).toBeFalsy();
       });
   };
  </code></pre>