REST API를 WebDriver에 통합 할 수 있습니다. 나는 이것에 종사하고 매력 같이 작동한다.
서비스 레이어 기능 : 자바 객체로이 데이터를 읽기 위해서는
/**
* This function will retrieve the child nodes under the current TG element
* @param webDriver The WebDriver reference
* @param element The Web Element whose child nodes are to be retrieved
* @return List<WebElement> The list of Child Elements for element.
* @throws Exception
*/
public static List<WebElement> getChildElements(WebElement element,WebDriver webDriver) throws Exception {
try{
List<WebElement> elementChilds = element.findElements(By.xpath(GlobalTreeGridValues.TreeGrid.TG_Shared_NextLevelXPath));
System.out.println("Avaialble child nodes for the current node are "+ element.findElements(By.xpath(GlobalTreeGridValues.TreeGrid.TG_Shared_NextLevelXPath)).size());
return elementChilds;
}catch(ElementNotFoundException ex){
System.out.println("Error in getting the XPath "+ ex.getMessage());
return null;
}
}
, 우리는 단지 HttpClient를 등
읽기 대한 추가 정보를 원하시면 http://code.google.com/p/json-io/ 같은 JSON 포매터 및 라이브러리를 필요로한다!
카일, 답변 주셔서 감사합니다.이 스크립트는 요소의 존재 여부 만 확인하고 있지만 웹 페이지의 콘텐츠를 확인하고 API 호출의 응답과 비교하는 방법은 무엇입니까? 건배. Zied – Ziwdigforbugs
@Ziwdigforbugs API 호출이 완료되면 HTML을 업데이트하십시오. Selenium을 사용하여 HTML 요소를 검사하십시오. 더 정교한 JSON 응답을 확인하는 것이 필요한 경우에는 Selenium 이외의 도구를 직접 사용하십시오. – KyleM