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

Screen.click(pattern) returns FindFailed error right after screen.has(pattern) returned true. #604

Closed
ghevge opened this issue Oct 26, 2023 · 2 comments

Comments

@ghevge
Copy link

ghevge commented Oct 26, 2023

I'm trying to click a page element using a BufferedImage pattern to detect it. The check for the pattern using screen.has(botDetected) is working fine when the element is present, but when I try to click that element, I get a FindFailed error.

My code looks something like this:

 BufferedImage image = ImageIO.read(this.getClass().getClassLoader().getResourceAsStream("press_hold.png"));
 Pattern botDetected = new Pattern(image);
.....
String webContent = getPageContent(currentURL);  
        
if (screen.has(botDetected)) {
    System.out.println("Element is present");
    screen.click(botDetected);
}
.......

The error I get, when calling screen.click(botDetected); is:

FindFailed: __BufferedImage__: (267x118) seen at (176, 343) with 1.00 in R[0,0 1920x954]@S(0)
  Line 2226, in file Region.java

I use sikulixapi 2.0.5, with selenium-java 4.14.1 in a spring app with OpenJDK 17.

Any idea what is going on?

Thanks

@ghevge
Copy link
Author

ghevge commented Oct 26, 2023

Hmm... This error/behavior seems to pop up only when I am in debug mode.
I'm using Eclipse on OpenJDK 17

Version: 2022-03 (4.23.0)
Build id: 20220310-1457

@RaiMan
Copy link
Owner

RaiMan commented Nov 29, 2023

Surely a problem of visibility (window to be searched in should be in front).
In debug mode the Eclipse window comes back to front when arriving at breakpoints.

Make sure that at least the relevant part of the window stays visible all the time or run with 2 monitors.

@RaiMan RaiMan closed this as completed Nov 29, 2023
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