获取工具栏';Android';用户界面集成测试框架
我有一个片段,它将用户当前正在编辑的实体的标题设置为:获取工具栏';Android';用户界面集成测试框架,android,testing,android-uiautomator,Android,Testing,Android Uiautomator,我有一个片段,它将用户当前正在编辑的实体的标题设置为: Activity activity = this.getActivity(); CollapsingToolbarLayout appBarLayout = (CollapsingToolbarLayout) activity.findViewById(R.id.toolbar_layout); if (appBarLayout != null) { appBarLay
Activity activity = this.getActivity();
CollapsingToolbarLayout appBarLayout = (CollapsingToolbarLayout) activity.findViewById(R.id.toolbar_layout);
if (appBarLayout != null) {
appBarLayout.setTitle(mItem.name);
}
class DetailWrapper {
protected UiObject2 find( BySelector selector ){
device.wait(Until.findObject(selector), 2 * 1000);
return device.findObject(selector);
}
public ItemView hasName(String itemName) throws Exception {
UiObject2 title = find(By.text(itemName));
assertEquals(title.getText(), itemName);
return this;
}
}
在测试代码中,我成功地导航到片段,但是我无法通过以下文本定位元素:
Activity activity = this.getActivity();
CollapsingToolbarLayout appBarLayout = (CollapsingToolbarLayout) activity.findViewById(R.id.toolbar_layout);
if (appBarLayout != null) {
appBarLayout.setTitle(mItem.name);
}
class DetailWrapper {
protected UiObject2 find( BySelector selector ){
device.wait(Until.findObject(selector), 2 * 1000);
return device.findObject(selector);
}
public ItemView hasName(String itemName) throws Exception {
UiObject2 title = find(By.text(itemName));
assertEquals(title.getText(), itemName);
return this;
}
}
hasName(String)中的title在assert中始终为null,尽管它位于具有正确标题的正确活动中。断言AppBar标题的最佳方法是什么