← Back to team overview

sikuli-driver team mailing list archive

[Question #674145]: What is the correct way to click on drop-down menus that highlight?

 

New question #674145 on Sikuli:
https://answers.launchpad.net/sikuli/+question/674145

In my test application, I have a drop-down menu whose entries highlight when the mouse pointer is over them. This seems to give Sikuli some difficulties. i.e. Sikuli can find the menu item, but the highlighting seems to sometimes make it lose it before it can click.

I think there may also be difficulties being caused by some Swing event timing issues. 

This code works reliably, but I'd like to know if there is a more elegant way to do this that is as reliable.

        // Hover, then click, since hovering will cause the menu item to highlight, and that seemed to cause a race where it wouldn't always click
        appWindow.hover(OpenNotebook);
        appWindow.click(HighlightedOpenNotebook);
        Debug.action("Clicked OpenNotebook.");
        try {
            appWindow.wait(NotebookOpenDialog, 2);
        } catch (FindFailed reclick) {
            Debug.action("Initial Open Notebook click failed.");
            try {
                appWindow.wait(HighlightedOpenNotebook, 1);
                appWindow.click(HighlightedOpenNotebook);
            } catch (FindFailed ignored) {
                appWindow.click(MoreActions);
                // Hover, then click, since hovering will cause the menu item to highlight, and that seemed to cause a race where it wouldn't always click
                appWindow.hover(OpenNotebook);
                appWindow.click(HighlightedOpenNotebook);
            }
        }


Even with this hover on the unhighlighted menu item and clicking on the highlighted one, I see the initial click fail about 1 in 10 times, and fall through to the retry.

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.