Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

View is not visible and can therefore not be clicked! #28

Closed
GoogleCodeExporter opened this issue Mar 24, 2015 · 10 comments
Closed

View is not visible and can therefore not be clicked! #28

GoogleCodeExporter opened this issue Mar 24, 2015 · 10 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Try to invoke clickOnView many times


What is the expected output? What do you see instead?
I got following exception
junit.framework.AssertionFailedError: View is not visible and can therefore not 
be clicked!
at com.jayway.android.robotium.solo.Clicker.clickOnScreen(Clicker.java:151)
at com.jayway.android.robotium.solo.Clicker.clickOnScreen(Clicker.java:127)
at com.jayway.android.robotium.solo.Solo.clickOnView(Solo.java:718)
at actester.testgenerator.ACTestGenerator.testActivity(ACTestGenerator.java:57)
at tt.hh.test.MyInstrumentTest.testUsingLib(MyInstrumentTest.java:35)
at java.lang.reflect.Method.invokeNative(Native Method)
at 
android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:204)
at 
android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:194)
at 
android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTes
tCase2.java:186)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at 
android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:52
0)
at 
android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)



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

1.9.0
Please provide any additional information below.


Original issue reported on code.google.com by lionghos...@gmail.com on 15 Nov 2010 at 12:56

@GoogleCodeExporter
Copy link
Author

Hi,

Can you please give some more details? Are you trying to invoke clickOnView() 
with the same parameter many times? Do you use a goBack() between the clicks 
etc etc.

Original comment by renasr...@gmail.com on 15 Nov 2010 at 1:10

@GoogleCodeExporter
Copy link
Author

I use following code to invoke it
public void testActivity(ActivityInstrumentationTestCase2<?> test,
            Instrumentation ins, Activity ac) {
        solo = new Solo(ins, ac);
        Random random = new Random(1234);
        int i = 0;
        ArrayList<View> views=null;
        Activity currentActivity = solo.getCurrentActivity();
        Activity previousActivity=currentActivity;
        while (i++ < 1000) {
            Log.i(ACTESTER,""+i);
            /*
             * We must use getViews() each time to get new list of views
             * because views on a single Activity may be updated
             */
            views=solo.getViews(); 
            if (currentActivity.hasWindowFocus()) {
                View v = views.get(random.nextInt(views.size()));
                if (v.isEnabled()&&v.isShown() ) {
                    Log.i(ACTESTER, "click "+v.toString());
                    try{
                        solo.clickOnView(v);
                        //TouchUtils.clickView(test, v);
                    }catch (Exception e) {
                        Log.i(ACTESTER,e.toString());
                    }
                    Log.i(ACTESTER, "finished click "+v.toString());
                }
            }else{
                currentActivity=solo.getCurrentActivity();
                if(currentActivity==previousActivity){
                    //some dialog pop up
                    solo.goBack();
                    Log.i(ACTESTER,"Go back");
                }else{
                    //a new Activity is created on top of the task stack
                    previousActivity=currentActivity;
                    Log.i(ACTESTER, "Change Activity to "+currentActivity);
                }
            }
        }
    }

Original comment by lionghos...@gmail.com on 15 Nov 2010 at 1:13

@GoogleCodeExporter
Copy link
Author

It happens when the code runs hundreds of times.

Original comment by lionghos...@gmail.com on 15 Nov 2010 at 1:15

@GoogleCodeExporter
Copy link
Author

This does not occur when you use TouchUtils instead?

Original comment by renasr...@gmail.com on 15 Nov 2010 at 1:32

@GoogleCodeExporter
Copy link
Author

I mean the exact same test case but instead of solo.clickOnView using 
TouchUtils.clickView(). How does that work?

Original comment by renasr...@gmail.com on 15 Nov 2010 at 1:33

@GoogleCodeExporter
Copy link
Author

TouchUtils is OK.

Original comment by lionghos...@gmail.com on 15 Nov 2010 at 1:34

@GoogleCodeExporter
Copy link
Author

Replacing the call to solo.clickOnView() with TouchUtils.clickView() in the
code I provided and that is the way I used TouchUtils.clickView().

Original comment by lionghos...@gmail.com on 15 Nov 2010 at 1:41

@GoogleCodeExporter
Copy link
Author

What happens is the following:

if(!view.isShown())
Assert.assertTrue("View is not visible and can therefore not be clicked!", 
false);

Basically it asks the view if it is shown. And that is after it has waited for 
5 seconds. So the view is telling Robotium that it is not shown (says so for 5 
seconds). Therefore Robotium fails it as it will not be able to click it (it 
thinks that it is not shown).

Original comment by renasr...@gmail.com on 15 Nov 2010 at 2:26

@GoogleCodeExporter
Copy link
Author

Thanks for this issue. This method will be rewritten in the next release.

Original comment by renasr...@gmail.com on 15 Nov 2010 at 3:47

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

This issue has been resolved in Robotium 2.0

Original comment by renasr...@gmail.com on 7 Dec 2010 at 7:38

  • Changed state: Verified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant