Robotium - 尝试点击应用按钮家 [英] Robotium - Trying to click home button in app
问题描述
我是新来的 robotium
,我想写一个快速和肮脏的脚本,通过一个应用程序的所有屏幕运行。
问题我主要用在应用程序中的主页按钮。我试过很多的选择,但我似乎无法得到它的点击除非有索引,这不是我想要的。
当我检查出的按钮 hierarchyviewer
它看起来是这样的:
然而,当我尝试,例如:
assertTrue(
等文字(ID:myapp.R.id.home)失败。
solo.waitForImageById(myapp.R.id.home,20000));
solo.clickOnImage((ImageView的)solo.findViewById(myapp.R.id.home));
solo.waitForActivity(MenuActivity);
它未能在 waitForImageByID
行。香港专业教育学院试图像 waitForImageButton
等多种选择,但我只是不能似乎得到它的点击。我在这里丢失怎么办?
junit.framework.AssertionFailedError:查看ID为:0没有找到!
在com.jayway.android.robotium.solo.Solo.getView(Solo.java:1990)
在com.jayway.android.robotium.solo.Solo.getView(Solo.java:1970)
在com.bitbar.recorder.extensions.OtherUtils.a(OtherUtils.java:246)
在com.bitbar.recorder.extensions.OtherUtils.b(OtherUtils.java:241)
在com.bitbar.recorder.extensions.v.a(Waiter.java:71)
在com.bitbar.recorder.extensions.ExtSolo.waitForImageButtonById(ExtSolo.java:4176)
在com.example.android.apis.test.Test.testRecorded(Test.java:137)
在java.lang.reflect.Method.invokeNative(本机方法)
在android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
在android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
在android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
在android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
在android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)
在android.app.Instrumentation $ InstrumentationThread.run(Instrumentation.java:1740)
使用以下行以preSS操作栏中的主页按钮
solo.clickOnActionBarHomeButton();
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:
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)
Use the following line to press the home button in the action bar
solo.clickOnActionBarHomeButton();
这篇关于Robotium - 尝试点击应用按钮家的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!