nickylin / nativedriver

Automatically exported from code.google.com/p/nativedriver
Apache License 2.0
0 stars 0 forks source link

Click doesn't work after scrolling #3

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I have a test for an activity that just about fills the screen in portrait mode 
and has a button at the bottom (about half of it is visible in landscape mode).

On portrait mode, clicking on it works fine (using 
driver.findElementByPartialText(buttonText).click()). However, when switching 
to landscape, the same test no longer works. The button is found, and it 
scrolls down until it becomes visible, but click() doesn't seem do anything.

I've noticed this on a different test when trying to click on a spinner, it 
scrolled and then clicked on a different element that now showed up where the 
spinner used to be.

Original issue reported on code.google.com by androidc...@gmail.com on 5 Jul 2011 at 10:15

GoogleCodeExporter commented 9 years ago
I believe this may have something to do with the fact that the entire thing is 
in a scrollview and that might mess things up.

Original comment by androidc...@gmail.com on 5 Jul 2011 at 11:58

GoogleCodeExporter commented 9 years ago
It also appears that only the first click after automatically scrolling to 
bring the element into view is stale. The next clicks work properly.

Original comment by androidc...@gmail.com on 6 Jul 2011 at 5:11

GoogleCodeExporter commented 9 years ago
Found the problem.

What happens is when calling view.requestRectangleOnScreen, while that is 
executed with the sync runner, it is animating so then the click goes to an old 
position.

This fixes it in ViewElement.java:

return view.requestRectangleOnScreen(rect, true); 

The true parameter will disable animation when scrolling so the coordinates of 
the view are updated immediately and clicks work as expected.

Original comment by androidc...@gmail.com on 6 Jul 2011 at 5:43

GoogleCodeExporter commented 9 years ago
To @androidcave: Yes, you are right. Thanks for the investigation and solution.

Original comment by d...@google.com on 19 Jul 2011 at 12:47

GoogleCodeExporter commented 9 years ago
I actually found that disabling all animations in the emulator makes things a 
lot smoother, maybe put that as a recommendation in your getting started page.

Original comment by androidc...@gmail.com on 20 Jul 2011 at 2:57