austgl / robotium

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

clickOnText() and clickLongOnText() should have an onlyVisible argument #244

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use ViewPager that contains multiple Fragments and only 1 is visible.
Sample: 
http://code.google.com/p/anymemo/source/browse/src/org/liberty/android/fantastis
chmemo/ui/AnyMemo.java
2. clickOnText should be able performed on the visible fragment

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

Please provide any additional information below.

searchText have onlyVisible argument, why not clickOnText?
public boolean searchText(String text, int minimumNumberOfMatches, boolean 
scroll, boolean onlyVisible) {

Original issue reported on code.google.com by mrlhwlib...@gmail.com on 7 Apr 2012 at 5:28

GoogleCodeExporter commented 9 years ago
The click methods only click on visible views. I think your issue is due to:

Why do text and button clicks get wrong?

http://code.google.com/p/robotium/wiki/QuestionsAndAnswers

Original comment by renasr...@gmail.com on 9 Apr 2012 at 9:47

GoogleCodeExporter commented 9 years ago
Adding <supports-screens android:anyDensity="true"/> doesn't work for me. In 
hierarchyview, it shows 4 child of a frameview for a ViewPager. Even only the 
2nd fragment is visible, Robotium will try to click the first fragment.

Original comment by mrlhwlib...@gmail.com on 9 Apr 2012 at 10:45

GoogleCodeExporter commented 9 years ago
Would it be possible for you to send me a sample app that exhibits this problem?

Original comment by renasr...@gmail.com on 10 Apr 2012 at 6:18

GoogleCodeExporter commented 9 years ago
You can download the AnyMemo 9.0 beta 11's apk:
http://code.google.com/p/anymemo/downloads/list

I have removed the problematic tests in the code but you an try
clickOnText("Open");
clickOnText("french-body-parts.db");

The implementation of this activity is here:
http://code.google.com/p/anymemo/source/browse/src/org/liberty/android/fantastis
chmemo/ui/AnyMemo.java

Original comment by mrlhwlib...@gmail.com on 10 Apr 2012 at 6:25

GoogleCodeExporter commented 9 years ago
This works for me:

solo.clickOnText("Open");
solo.clickOnText("french*", 2);
solo.clickOnText("Study");

The issue you are experiencing is because there are two text views: 
french-body-parts.db. They both have valid locations and both answer true when 
asked textView.isShown(). Therefore Robotium does not know that only the  
second one is visible to the user. Therefore I have added the parameter 2 in 
clickOnText() so that the second match is clicked. 

Original comment by renasr...@gmail.com on 10 Apr 2012 at 9:10

GoogleCodeExporter commented 9 years ago
Ok, I see. ViewPager did make views invisible, instead, it put it outside of 
the viewing area.

Actually I figured out the real problem is that Robotium can't scroll down in 
ViewPager. Use the same AnyMemo app I linked before try this test on a device 
with small screen (You need to scroll down in order to click "About" in "Misc" 
tab.

solo.clickOnText("Misc");
solo.clickOnText("About");

The test will fail because Robotium don't know how to scroll down.

BTW, if you want to discuss this in a new ticket, I will open another one.

Original comment by mrlhwlib...@gmail.com on 10 Apr 2012 at 9:19