2017-12-31 74 views
-1
<i> 
@FindAll(@FindBy(xpath = ".//input[contains(@name,'adv_xfer_fields') 
and contains(@name,'::amounts')]")) 
List <WebElement> amounts; 
</i> 

입력란에 동적 웹 테이블이 있습니다. 이상적으로이 값을 전달해야합니다. 그러나 이것을 구현하는 방법을 모르겠습니다.List FindALL webelement 구현 방법

public List<WebElement> getAllAmounts() { 
    return amounts; 
} 

+1

FindBy 기준이 하나뿐이므로 FindAll을 사용해야하는 이유는 무엇입니까? 이것을 참조하십시오 - https://stackoverflow.com/questions/25914156/difference-between-findall-and-findbys-annotations-in-webdriver-page-factory – Grasshopper

답변

0

귀하의 질문에 따라, 나는이 밖으로 시도 코드에서 오류가 표시되지 않습니다 도움이되지만 확실히 우리는 다음과 같이 좀 더 정확한 구성 할 수 있습니다하십시오

 @FindAll({@FindBy(xpath = ".//input[contains(@name,'adv_xfer_fields')]"), 
       @FindBy(xpath = ".//input[contains(@name,'::amounts')]")}) 

     List <WebElement> amounts; 

설명서에 따라 FindAll은 일련 번호 @FindBy 태그를 사용해야 함을 나타 내기 위해 페이지 개체의 필드를 표시하는 데 사용됩니다. 그런 다음 요소가 문서 순서에 있음을 보장하지는 않지만 FindBy 기준과 일치하는 모든 요소를 ​​검색합니다.

+0

이 문제는 유효한 FindAll이지만 원본 게시물에 "and"조건이 있고 예제에서 "or"조건을 제공합니다. FindBy가 찾은 것이므로 해결책은 바깥 쪽 FindAll을 제거하고 나머지는 원래 포스터의 위치 정보를 유지하는 것입니다. –