Skip to content
Discussion options

You must be logged in to vote

Late reply here, since I didn't check discussions regularly.

One way to achieve your goal would be to use a catch block.
In case the image is not found, the find Promise will reject, thus you could move the mouse conditionally in this case.

Something like

async function demo() {
    try {
        const targetRegion = await screen.find("image.png");
        await mouse.move(straightTo(centerOf(targetRegion)));
    } catch (e) {
        await mouse.move(down(10));
    }
}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@louisho5
Comment options

@s1hofmann
Comment options

Answer selected by s1hofmann
# for free to join this conversation on GitHub. Already have an account? # to comment
Category
Q&A
Labels
None yet
2 participants