It is ofcourse possible to integrate REST API to WebDriver. I have worked on this and it works like a charm.
Service Layer Function:
/**
* 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;
}
}
In order to read this data into a java object, we just need json formatters and libraries like httpclient etc.
Read http://code.google.com/p/json-io/ for more info!