Skip to content

Add More Detail to WaitFor() Timeout Errors #556

Closed
@joel-duffie

Description

@joel-duffie

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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions