title: TestCafe - How to check if a web element exists or does not exist without failing the test?
body: <p>I'm trying to write a script that needs to adapt it's workflow behavior depending on whether a particular browser object found by CSS selector exists or does not exist.</p>
  
  <p>I do not want to use a document.getElementByID method as this is not technically a CSS selector, and our entire enterprise is standardized on CSS selector so anything that walks the DOM other then a CSS selector won't make it past our code review process anyway.</p>
  
  <pre><code>var thing = await things.thingSelector(thingName);
  if (await t.expect(thing.exists).notOk()) {
     await t.click(things.OpenThing(thingName));
  } else {
     return false;
  }
  return true;
  </code></pre>
  
  <p>Where thingSelector is:</p>
  
  <pre><code>const thingSelector = name =&gt;
    Selector('p.thing-header-title span')
      .withText(name)
      .parent('div.thing');
  </code></pre>
  
  <p>Where OpenThing is:</p>
  
  <pre><code>const OpenThing = name =&gt;
      thingSelector(name)
          .find('a.thing-footer-item')
          .withText('Open');
  </code></pre>
  
  <p>I need to be able to continue execution if the object is not there and I'm checking that it exists, or if the object is there and I'm checking that it does not exist, and also the cases where the object is not there and it does not exist and the object is not there and I'm checking that it does not exist.</p>
  
  <p>In all cases I still need to proceed with the workflow.</p>
  
  <p>I've tried both sides of the logic coin:</p>
  
  <pre><code>if (!await t.expect(thing.exists).ok())
  </code></pre>
  
  <p>And</p>
  
  <pre><code>if (await t.expect(thing.exists).notOk())
  </code></pre>
  
  <p>If one of the above doesn't fail in one scenario it will fail in the other, and the other one will fail in the scenario that the first one didn't fail. I need something that will give me the logic, but not ever fail the script execution and still allow me to return either True or False depending on if the object is present or not present.</p>
  
  <p>Thank you in advance for helping me to solve this problem, and also to learn and grow in my Javascript skills!</p>