-3
String spath = ".//*[@id='container']/div/div[2]/div/div/div[";
String epath = "]/div[2]";
for(int i = 1; i < 5; i++) {
String tpath = spath+i+epath;
WebElement listpath = h.findElement(By.xpath(tpath));
String list = listpath.getText();
System.out.println(list);
}
위해 XPath에있는 단위를하는 별개의 변수에 각 웹 요소를 저장, 하지만 각각 각 웹 요소 각 변수에 저장할 필요가 있습니까?어떻게 인덱스가 나는 <strong>단일</strong> 변수 "<strong>목록</strong>"의 모든 <strong>웹 요소를</strong> 저장 한이 경우 각 웹 요소
페이지 또는 관련 HTML에 대한 링크와 목표가 무엇인지에 대한 설명을 게시하십시오. – JeffC