点击按钮不起作用

发布于 2024-10-20 00:56:01 字数 1894 浏览 1 评论 0原文

我是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鸠魁 2024-10-27 00:56:01

您确定按钮的名称是这样的“应用程序” android:text="Application" 吗?

Are you sure the name of the button is Application like this android:text="Application"?

挽袖吟 2024-10-27 00:56:01

你确定这是一个按钮吗?尝试使用 clickOnText() 代替。

Are you sure it is a button? Try clickOnText() instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文