namjae / robotium

Automatically exported from code.google.com/p/robotium
0 stars 0 forks source link

Add functionality to click on menu item text when number of menu items is more than six #20

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This is feature request, I have written this in my test code as following, 
would be nice to have this method in Solo.

protected void selectMenuOption(String menuOption)
    {
        this.solo.sendKey(Solo.MENU);
        // if menu item exists then click on it else click on menu
        if (this.solo.searchText(menuOption, 0, false))
        {
            this.solo.clickOnText(menuOption, 0, false);
        }
        else
        {
            this.solo.clickOnText("More", 0, false);
            this.solo.waitForText(menuOption);
            this.solo.clickOnText(menuOption, 0, false);
        }
    }

Original issue reported on code.google.com by aman.bha...@gmail.com on 15 Oct 2010 at 9:48

GoogleCodeExporter commented 9 years ago
Hi, this functionality already exists:
clickOnMenuItem(String text, boolean subMenu)

Original comment by renasr...@gmail.com on 15 Oct 2010 at 10:00

GoogleCodeExporter commented 9 years ago
Sorry, didn't realize the method   clickOnMenuItem(String text, boolean 
subMenu)  already exists.

But as a usability thing why not just keep one method as  
clickOnMenuItem(String text)
and let it take care of more menu options rather than overloading.    Is it 
because of backward compatibility.

Original comment by aman.bha...@gmail.com on 15 Oct 2010 at 10:13

GoogleCodeExporter commented 9 years ago
It is because of backward compability. The clickOnMenuItem(String text, boolean 
subMenu) was first implemented in 1.7.0.

Original comment by renasr...@gmail.com on 16 Oct 2010 at 2:39

GoogleCodeExporter commented 9 years ago
Also becuase "More" is not always called More (localization issues) so 
basically the only way to know that the button is actually More is if there are 
6 text fields in the menu. That however could mean that the 6th text field is 
not a more and then this feature would fail. That is why the subMenu parameter 
is needed.

Original comment by renasr...@gmail.com on 16 Oct 2010 at 2:45

GoogleCodeExporter commented 9 years ago
Thanks for the explanation, I have just one more comment/clarification:
the way code for clickOnMenuItem(String text, boolean subMenu) is written, it 
first checks if there is textMore on screen, if it exists then it clicks it 
otherwise it just directly clicks on text. So the extra param can be removed 
and clickOnMenuItem always do this
 if(textMore != null)
clickOnScreen(textMore);

clickOnText(text, false, 1, false);

Original comment by aman.bha...@gmail.com on 16 Oct 2010 at 3:06