hellofenghao / robotium

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

Robotium fails to scroll to click on off-screen menu item. #550

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

I have an app that uses ActionBarSherlock and has seven menu items.
On some phones, when in landscape mode, the screen only has room to display 6 
menu items. The 7th one is off screen and the user should scroll the menu list 
up to make it visible and click on it.
I have a test that attempts to click on that last menu item with a call like 
this

mySoloObject.clickOnMenuItem("My menu label", true);

What is the expected output? What do you see instead?

I would expect Robotium to scroll up to make the "My menu label" menu item 
visible and then click on it.
Instead Robotium clicks on the preceding entry (the last menu item that is 
visible at the bottom of the screen)

What version of the product are you using? On what operating system?

This happens on ICS and up as far as I can tell.
On GB devices there is an overflow submenu and Robotium deals with that as 
expected.

Original issue reported on code.google.com by denis...@gmail.com on 5 Nov 2013 at 5:44

GoogleCodeExporter commented 9 years ago
Thanks for reporting this.

Original comment by renasr...@gmail.com on 7 Nov 2013 at 4:30

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Out of curiosity I pulled the Robotium source code and traced through it to see 
what happens. 

In the Clicker class, in the clickOnMenuItem(String text, boolean subMenu) 
method, I modified the following call

        boolean textShown = waiter.waitForText(text, 1, WAIT_TIME, false) != null;

I changed the last parameter's value from false to true, like this

        boolean textShown = waiter.waitForText(text, 1, WAIT_TIME, true) != null;

This allows for scrolling in order to find the text. I haven't tested this 
change exhaustively and I'm not familiar enough with the Robotium code to be 
able to say confidently that this doesn't introduce any side effects / new bugs 
/ regressions though. 

Original comment by druckebu...@netflix.com on 7 Nov 2013 at 8:53

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Thanks.

Original comment by renasr...@gmail.com on 8 Nov 2013 at 6:04

GoogleCodeExporter commented 9 years ago
The only way we've found to fix this is by doing the click directly from 
Javascript. Please use Robotium 5.0.1. In the new Config class, set:

conf.useJavaScriptToClickWebElements = true

See the javadoc on how to use the Config class. 

Original comment by renasr...@gmail.com on 6 Jan 2014 at 7:57