Click on button not working
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 {开发者_JAVA技巧
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)
Are you sure the name of the button is Application like this android:text="Application"?
Are you sure it is a button? Try clickOnText() instead.
精彩评论