Closed GoogleCodeExporter closed 9 years ago
You can do the following:
ImageButton imageButton = (Image) solo.getView(R.id.of.imagebutton);
solo.clickOnView(imageButton);
Original comment by renasr...@gmail.com
on 24 Jul 2011 at 3:12
Sometimes the emulator is too slow, so when I call
solo.getView(R.id.of.imagebutton) it will return null. I had to add a
solo.sleep(1000) before it, which isn't always enough. It also seems silly to
me, of putting solo.sleep() everywhere just to make the code more reliable.
With the - not so clean - method of using the loop I never encountered this
issue, because solo.getCurrentImageButtons() always returned all of the
ImageButtons.
Is there no cleaner _and_ more reliable method of using the loop? Because I
will probably revert to using the loop if there is not.
Original comment by aried3r
on 26 Jul 2011 at 3:11
I agree, using sleeps is not a good solution. Try this:
solo.waitForView(ImageButton.class);
ImageButton imageButton = (Image) solo.getView(R.id.of.imagebutton);
solo.clickOnView(imageButton);
If you want to be even more specific you can use:
solo.waitForView(final Class<T> viewClass, final int minimumNumberOfMatches,
final int timeout)
Original comment by renasr...@gmail.com
on 26 Jul 2011 at 3:39
Thank you. This worked out nicely.
Original comment by aried3r
on 29 Jul 2011 at 9:03
I wrote that within my code to click on an image button ...
solo.waitForView(ImageButton.class);
ImageButton imageButton = (ImageButton)
solo.getView("com.softxpert.sds.R.id.addFolderAction");
solo.clickOnView(imageButton);
BUT, It doesn't work and here's the error .. any help ?
junit.framework.AssertionFailedError: View with id:
'com.softxpert.sds.R.id.addFolderAction' is not found!
at com.robotium.solo.Solo.getView(Solo.java:1990)
at com.robotium.solo.Solo.getView(Solo.java:1970)
at
com.example.android.apis.test.test.AddIconTest3.testRecorded(AddIconTest3.java:5
7)
at java.lang.reflect.Method.invokeNative(Native Method)
at
android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at
android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at
android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTes
tCase2.java:192)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at
android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:54
5)
at
android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1575)
Original comment by glamour....@gmail.com
on 23 Feb 2014 at 8:24
Try to use this as the I'd string instead: addFolderA
Original comment by renasr...@gmail.com
on 23 Feb 2014 at 2:28
Original issue reported on code.google.com by
aried3r
on 22 Jul 2011 at 1:07