내 페이지 팩토리 모델에서 동적 요소를 만드는 데 사용하는 아래 mwthod입니다. IOSClassChain 값을 문자열로 전달한 다음이를 요소로 변환합니다. 요소가 페이지에있을 때 잘 작동하지만 요소가 없을 때 null을 반환합니다. 다음은 방법 :요소가 발견되지 않으면이 메서드가 null을 반환하지 않게하려고합니다.
public MobileElement mobileElementUsingIOSClassChain(String objElement) throws IOException {
MobileElement objMobileElement = null;
try {
objMobileElement = (MobileElement) ((AppiumDriver) GetDriver()).findElement(ByIosClassChain.iOSClassChain(objElement));
} catch (Exception e) {
System.err.println("Element not found");
}
return objMobileElement;
}
내가 objElement에 대한 통과하고 값은 다음과 같습니다
String elementStr = "**/XCUIElementTypeButton[`label=='Name'`]"
어떤 제안?
그럼 무엇을 반환 하시겠습니까? 아니면 전혀 돌아 오지 않고 Exception을 throw해야합니까? –
선택 사항 –
선택 사항은 IMHO가 합당한 예외 처리를위한 적절한 대안이 아닙니다 .... –