react-native目前通过accessibilityLabel支持contentDescription。这对于可点击的元素非常有用,但是在添加唯一ID后,使用appium inspector / UI automator甚至开发人员测试其他内容(例如启动画面可见性/文本框)并不是很好。
谁可以帮我这个事。
如果在启动画面中有对比,则可以使用isDisplayed()方法检查屏幕是否显示。
public boolean isSplashScreenVisible(){
try{
MobileElement element = driver.findElementByAccessibilityId("automation id here");
return element.isDisplayed();
}catch(Expection e){
return false;
}
}
或者,您可以检查是否显示启动画面;
List<MobileElement> element = driver.findElementsByAccessibilityId("automation id here");
if(element.size()>0){
//screen is displayed
}else{
//screen is not displayed
}