点击按钮不起作用
我是 robotsium 的新手,现在我正在自动化该应用程序。
应用程序以初始屏幕启动,然后在加载 1ndicator 15 秒后显示菜单屏幕,菜单屏幕中有一个名为 Application 的按钮。当我继续单击该按钮时,它会返回错误。
注意:当我使用搜索文本时,它会返回具有名称的按钮
protected void setUp() throws Exception {
solo = new Solo(getInstrumentation(), getActivity());
}
public void testCanOpenSettings() throws Exception {
String appName = solo.getCurrentActivity().getClass().getSimpleName();
System.out.println(appName);
String appName1 = solo.getCurrentActivity().getClass().getSimpleName();
System.out.println(appName1);
solo.assertCurrentActivity("Home screen", appName1);
solo.waitForActivity(appName1, 10000);
solo.clickonbutton("Application");
}
@Override
public void tearDown() throws Exception {
try {
solo.finalize();
} catch (Throwable e) {
e.printStackTrace();
}
getActivity().finish();
super.tearDown();
}
堆栈跟踪:
junit.framework.AssertionFailedError: No Button with text Application is found!
at com.jayway.android.robotium.solo.ViewFetcher.getView(ViewFetcher.java:350)
at com.jayway.android.robotium.solo.Solo.getButton(Solo.java:1233)
at com.impiger.fff.controller.Test.testCanOpenSettings(Test.java:45)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:205)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:195)
at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:175)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:444)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)
I am new to robotium and now I am automating the app.
App starts with a splash screen and then the menu screen after 15 seconds of loading 1ndicator, in the menu screen there is a button named Application. When I proceed with click on that button it returns an error.
NOTE: When I used search text it returns that button with name is present
protected void setUp() throws Exception {
solo = new Solo(getInstrumentation(), getActivity());
}
public void testCanOpenSettings() throws Exception {
String appName = solo.getCurrentActivity().getClass().getSimpleName();
System.out.println(appName);
String appName1 = solo.getCurrentActivity().getClass().getSimpleName();
System.out.println(appName1);
solo.assertCurrentActivity("Home screen", appName1);
solo.waitForActivity(appName1, 10000);
solo.clickonbutton("Application");
}
@Override
public void tearDown() throws Exception {
try {
solo.finalize();
} catch (Throwable e) {
e.printStackTrace();
}
getActivity().finish();
super.tearDown();
}
Stack trace:
junit.framework.AssertionFailedError: No Button with text Application is found!
at com.jayway.android.robotium.solo.ViewFetcher.getView(ViewFetcher.java:350)
at com.jayway.android.robotium.solo.Solo.getButton(Solo.java:1233)
at com.impiger.fff.controller.Test.testCanOpenSettings(Test.java:45)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:205)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:195)
at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:175)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:444)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您确定按钮的名称是这样的“应用程序” android:text="Application" 吗?
Are you sure the name of the button is Application like this android:text="Application"?
你确定这是一个按钮吗?尝试使用 clickOnText() 代替。
Are you sure it is a button? Try clickOnText() instead.