일부 특정 조건에서 약간의 어려움이 있습니다.div가 숨겨져있을 때 요소를 찾을 수 없습니다.
오류가없는 경우 페이지는 다음과 같이 보입니다.
<script src="includes/js/errorHandling.js?v=5" type="text/javascript"/>
<div class="pmo_title">
<!--end pmo title-->
<div class="spacer2"/>
<div class="pmo-container">
그러나 오류가 발생하면 추가 div 클래스가 표시됩니다.
<script src="includes/js/errorHandling.js?v=5" type="text/javascript"/>
<div class="pmo_title">
<!--end pmo title-->
<div class="pmo_warning">
<div class="pmo-container">
<span class="message_title">Errors :</span>
<!--display first item of list with no comma-->
<span id="fileError" class="error">File to Upload required</span>
</div>
</div>
<div class="spacer2"/>
<div class="pmo-container">
유효하지 않은 파일을 업로드하고 오류가 표시되면 예외를 throw하는지 확인하고 싶습니다. 계속 진행하십시오.
: 는 다음 코드@FindBy(xpath = "//div[@class='pmo_warning']")
private WebElement errorMessage;
if (errorMessage !=null){
throw (new IOException("file not found"));
}
return initialize(driver, FileUpload.class);
그것은 내가 또한 표시 오류없이 파일을
@FindBy(xpath = "//div[@class='pmo_warning']")
private WebElement errorMessage;
if (errorMessage.IsDisplayed()){
throw (new IOException("file not found"));
}
return initialize(driver, FileUpload.class);
을 시도
모두 유효하고 유효하지 않은 입력에 대해 예외가 발생 썼다
Unable to lo 케이트 요소
감사합니다. 유일한 문제는 모두 찾기 대기 시간을 늘리는 것입니다. – user2410266
FindBy가 하나 밖에없는 FindAll 주석이 필요한 이유는 무엇입니까? FindAll은 목록에 언급 된 모든 FindBy에 대해 OR 연산자를 제공합니다. 이것 좀 봐 - http://stackoverflow.com/questions/25914156/difference-between-findall-and-findbys-annotations-in-webdriver-page-factory. FindAll을 제거하고 목록 선언을 단일 FindBy 주석과 함께 사용할 수 있습니다. –
Grasshopper
@Grasshopper FindBy는 단일 WebElement 만 반환합니다. 대신 FindAllBy를'@FindAllBy (How = How.CSS, = "div.pmo_warning"을 사용)로 사용할 수 있습니다. errorMessage' .. 감사합니다. ... –