Skip to content

Are there any ways to get the boolean value of screen.find? #339

Answered by s1hofmann
louisho5 asked this question in Q&A
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants