0

I'm using Cucumber.js running Typescript in Node.js to test a web app. I'm finding it impossible to check that an element doesn't exist in a page because if it doesn't, I always get thrown an error which I can't catch/suppress:

× failed

  Error: function timed out, ensure the promise resolves within 60000 milliseconds
      at Timeout.<anonymous> (C:\Users\......\node_modules\@cucumber\cucumber\src\time.ts:69:14)
      at listOnTimeout (internal/timers.js:554:17)
      at processTimers (internal/timers.js:497:7)

Already tried several approaches (example) but always get this error. Even the following simple code from the Selenium docs, using findElements():

async function isEnvironmentalDataButtonDisplayed() {
    await webDriver.findElements(By.id("does-not-exist")).then(found => console.log('Element found? %s', !!found.length));
}

I was aiming to be able to get a boolean with value about if the element exists or not. This problem is preventing me to write tests where I expect important information not to be displayed/present. Thanks.

Dependencies used: @types/selenium-webdriver@4.1.9 selenium-webdriver@4.6.1 @cucumber/cucumber@7.3.2 @types/cucumber@7.0.0 typescript@3.9.10 Node.js v12.22.6

jonypera
  • 446
  • 2
  • 13
  • 23

0 Answers0