nightwatch icon indicating copy to clipboard operation
nightwatch copied to clipboard

throw error in case of failure for programatic api

Open swrdfish opened this issue 2 years ago • 8 comments

Attempt to fix #2510

swrdfish avatar Nov 27 '22 23:11 swrdfish

Hi @swrdfish, any idea on this? I hope this PR won't be stalled. Really need a fix. Thanks!

tim-yao avatar Dec 07 '22 22:12 tim-yao

@tim-yao the fix is not as simple as I thought it would be. Hopefully we'll have some update by early next week.

swrdfish avatar Dec 08 '22 07:12 swrdfish

The only way to do this in a safe manner is to introduce a new settings which will be turned off by default. Something like the always_async_commands settings.

beatfactor avatar Dec 08 '22 08:12 beatfactor

Hi all. Happy to help on this if I can get some guidance. Really need this, as the issue makes the programmatic API basically useless.

tim-yao avatar Dec 20 '22 02:12 tim-yao

Hi all. Happy to help on this if I can get some guidance. Really need this, as the issue makes the programmatic API basically useless.

I think it should work fine if you set always_async_commands to true, which is the case in the cucumber runner.

beatfactor avatar Dec 20 '22 11:12 beatfactor

Hi @beatfactor I added always_async_commands but still the same. See this commit: https://github.com/nightwatchjs-community/cucumber-nightwatch/pull/9/commits/103ae61a2fa1ca1dd583fc40f3402cb74c715814 And test result: https://github.com/nightwatchjs-community/cucumber-nightwatch/actions/runs/3745075953/jobs/6359112950 Any idea?

tim-yao avatar Dec 20 '22 23:12 tim-yao

Hi all. Happy to help on this if I can get some guidance. Really need this, as the issue makes the programmatic API basically useless.

I think it should work fine if you set always_async_commands to true, which is the case in the cucumber runner.

Did some debugging today and I think the cucumber runner works because of this additional logic: https://github.com/nightwatchjs/nightwatch/blob/main/lib/core/asynctree.js#L95-L97

Should we add something like:

    if (this.programaticAPI) {
      return err.waitFor;
    }

tim-yao avatar Jan 12 '23 00:01 tim-yao

There are two more related issues I found in the programmatic API. They can be reproduced at https://github.com/nightwatchjs/cucumberjs-boilerplate.

  1. abortOnFailure option is not working. The below examples will fail the test step even though abortOnFailure is false.
await browser.waitForElementPresent('.not-existing-element', 100, false)
await browser.waitForElementPresent({
      selector: '.not-existing-element',
      retryInterval: 1000,
      abortOnFailure: false
    });
  1. click command won't fail. await browser.click('#not-existing-element') won't fail the step.

tim-yao avatar Jan 30 '23 07:01 tim-yao