我在这里有一个独特的情况。我正在使用Robotium测试一个应用程序,并且我是在“黑盒”条件下这样做的。在我的测试中,我有一个标题为' all‘的标签,它在屏幕的顶部,我想测试当它被点击时,所有可用项都会列出。然而,发生的事情是,点击标题为“高级呼叫管理器”的应用程序,而不是点击“全部”选项卡。我假设这是因为'all‘是'call’的一部分,由于Robotium的工作方式,即使它是'call‘的一部分,它也会点击'all’。在你看了我的代码之后,你可能会明白我的问题所在。
所以我的问题是:
有没有办法“重置”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\"");
}任何帮助都将不胜感激!
发布于 2012-07-04 06:08:55
传递给solo.clickOnText()的字符串实际上是一个RegEx。所以我认为你可以通过传递一个匹配“all”而不是“RegEx”的调用来解决你的问题。
发布于 2014-01-22 21:00:30
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);https://stackoverflow.com/questions/11319524
复制相似问题