Robotium - Trying to click home button in app

0
0

I’m new to robotium and i’m trying to write a quick and dirty script to run through all screens in an app.

The problem i have mainly with the ‘home button’ in the app. I’ve tried lots of options but i cant seem to get it to click there except with index, which is not what i want.

When i check out the button with the hierarchyviewer it looks like this:

Link

However when i try for example:

assertTrue(
"Wait for text (id: myapp.R.id.home) failed.",
solo
.waitForImageById("myapp.R.id.home", 20000));
solo
.clickOnImage((ImageView) solo.findViewById("myapp.R.id.home"));
solo
.waitForActivity("MenuActivity");

It fails at the waitForImageByID line. Ive tried multiple options like waitForImageButton etc, but i just cant seem to get it clicked. What am i missing here?

junit.framework.AssertionFailedError: View with id: '0' is not found!
at com
.jayway.android.robotium.solo.Solo.getView(Solo.java:1990)
at com
.jayway.android.robotium.solo.Solo.getView(Solo.java:1970)
at com
.bitbar.recorder.extensions.OtherUtils.a(OtherUtils.java:246)
at com
.bitbar.recorder.extensions.OtherUtils.b(OtherUtils.java:241)
at com
.bitbar.recorder.extensions.v.a(Waiter.java:71)
at com
.bitbar.recorder.extensions.ExtSolo.waitForImageButtonById(ExtSolo.java:4176)
at com
.example.android.apis.test.Test.testRecorded(Test.java:137)
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.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
at android
.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
at android
.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)
at android
.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1740)
  • You must to post comments
0
0

Use the following line to press the home button in the action bar

solo.clickOnActionBarHomeButton();
  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website