0

I have an application where I need to be able to log out and the only way to do so is to click on the Log out option in the drop down menu however I am having a lot of problems.

I have captured the screenshots using the Sikuli IDE and when I run my code from the IDE it works perfectly fine. (The code clicks on Menu and then Log out)

However when I try to run the code from Java it appears that it selects Menu and then when it tries to click Log out, the menu disappears.

My guess is that for some reason Java is putting the focus on the mouse before it moves to the Log out button and when the focus goes to the mouse the menu disappears as it does when you click elsewhere.

I have also tried making Sikuli press the down button several times to get to log out but the same thing happens when it tries: the menu disappears.`

This is my Java code. The Sikuli code has the same two click commands:

@Override
   public void logout()
   {
      click("loggedInIndicator.png");
      click("logoutButton.png");
   }

Please help! There is no other way to log out that I can find.

Ona_17
  • 35
  • 1
  • 8
  • I guess the other part of my question would be Has anyone ever succeeded in clicking a menu item using Java and Sikuli? (Even if your situations is slightly different). I would really like to know if it is even possible. – Ona_17 Aug 07 '12 at 17:58

1 Answers1

0

I suggest you to print the image Sikuli finds to be the best match for the elements. My guess is it selects a part of the screen that has nothing to do with the element you want to click on, making the menu disappear.

Match element = region.find("loggedInIndicator.png")
Screen screen = element.getScreen()
String imagePath = screen.capture(element)

This saves an image of the element found by Sikuli in the System temp directory. As it is a temporary file, you'll certainly have to move the freshly created image file to another directory so that it'll not be deleted immediately. I found this happening several times on Windows

Grooveek
  • 10,046
  • 1
  • 27
  • 37
  • Thanks for the quick reply. I'm pretty sure that matching is not the problem because the mouse does not move from the Menu button. It just flashes for a second as if it did click something. However, I know that it does NOT click the menu button again because on this particular application, when you click the menu button multiple times, the menu still stays open. Also, if I'm using the exact same images and everything as I am when I run it from the Sikuli IDE and the IDE works, you would think that it would work exactly the same way from the Java code – Ona_17 Aug 07 '12 at 17:40