点击按钮不起作用

问题描述:

我是robotium的新手,现在我正在自动化应用程序。点击按钮不起作用

应用程序从启动屏幕开始,然后在加载1ndicator 15秒后显示菜单屏幕,在菜单屏幕中有一个名为的应用程序。当我继续点击那个按钮时,它会返回一个错误。

注意:当我用搜索文本返回与名称键存在

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) 

确定按钮的名称是这样的Android应用程序:文字=“应用程序”?

+0

yes文本名称为应用程序 – user608211 2011-03-02 09:28:15

+0

根据您的代码“solo.clickonbutton(”Application“);”,都是小写字母,它必须是像“solo.clickOnButton(”Application“)这样的驼峰案例;” – exception01 2011-03-02 11:17:17

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