【问题标题】:"Resetting" Robotium searchText“重置” Robotium searchText
【发布时间】:2012-07-03 21:33:15
【问题描述】:

我在这里有一个独特的情况。我正在使用 Robotium 测试应用程序,并且在“黑盒”条件下执行此操作。在我的测试中,我有一个标题为“全部”的选项卡,它位于屏幕顶部,我想测试当它被单击时,所有可用的项目都会列出。但是,会发生什么,而不是单击“全部”选项卡,而是单击了名为“高级呼叫管理器”的应用程序。我认为这是因为“全部”是“呼叫”的一部分,并且由于 Robotium 的工作方式,即使它是“呼叫”的一部分,它也会点击“全部”。看了我的代码,你可能明白我的问题是什么了。

所以我的问题是:

有没有办法“重置”Robotium,以便在搜索文本时从页面顶部开始?这是我的代码:

solo.waitForText("all"); 
        bw.write("Verify presence of 'all' filter on " + BUSINESS + "-COMMUNICATION page\",\"");
        if(solo.searchText("all")==false){
            bw.write("FAILED \",\" \'all\' filter not found \"\n\"");               
        }else if(solo.searchText("all")==true){
            bw.write("PASSED \",\" \'all\' filter present\"\n\"");
            bw.write("Verify functionality of 'all' filter\",\""); 
            solo.clickOnText("all"); 
            solo.sleep(5000); 
            solo.takeScreenshot(); 
            bw.write("Screenshot taken\",\"" +"See photo: "+ photoFormat.format(new Date()).toString()+"\"\n\"");


        }

任何帮助将不胜感激!

【问题讨论】:

    标签: android testing junit automation robotium


    【解决方案1】:

    传递给solo.clickOnText() 的字符串实际上是一个RegEx。所以我认为你可以通过传递一个匹配'all'但不匹配'call'的正则表达式来解决你的问题。

    【讨论】:

      【解决方案2】:
      ViewGroup class will be helpful in this case as you are using tabs in your code.Now find the view using getChildAt() method.
      
      ViewGroup tabs = (ViewGroup) solo.getView(android.R.id.tabs);
      View viewYouWantToDoStuffWith = tabs.getChildAt(x); //change x to the index you want.
      
      Now you can perform the click event on tab like below.
      solo.clickOnView(viewYouWantToDoStuffWith);
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-08-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-08-09
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多