Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add More Detail to WaitFor() Timeout Errors #556

Closed
joel-duffie opened this issue Jan 31, 2024 · 1 comment
Closed

Add More Detail to WaitFor() Timeout Errors #556

joel-duffie opened this issue Jan 31, 2024 · 1 comment

Comments

@joel-duffie
Copy link

Short overview

The timeout error thrown for waitFor() could contain more details (similar to find() errors).

Use case

To debug issues more easily.

Detailed description

Currently, when I handle an error thrown by a waitFor call, the only message shown is:

Action timed out after XXXX ms

This message itself is vague, not to mention the absence of the stack trace in the error log.

I think giving a bit of context for where and what this error is, would be extremely helpful.

This is a very simple script which illustrates the point:

const nut = require('@nut-tree/nut-js');
const utils = require('./scripts/utilities');
require('@nut-tree/nl-matcher');

(async () => {
    try {
        nut.screen.config.resourceDirectory = utils.getImagesPath()
        await nut.screen.waitFor(nut.imageResource('continue_btn.png'), 1000);
    } catch (err) {
        console.error(err);
    }
})();
  • utils.getImagesPath() simply returns the path of my resource directory
  • assuming 'continue_btn.png' is present in the resource directory, but isn't on screen, this code should print the error message "Action timed out after XXXX ms"
s1hofmann added a commit that referenced this issue Feb 3, 2024
s1hofmann added a commit that referenced this issue Feb 3, 2024
s1hofmann added a commit that referenced this issue Feb 3, 2024
* (#556) Store intermediate results and errors to provide additional context on timeout

* (#556) Update testcases
@s1hofmann
Copy link
Member

Closed with release 4.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants