From: Brian M. <bm...@ya...> - 2008-02-27 20:51:20
|
We are trying to implement HTMLUnit at our client as part of our testing strategy. Many of our apps rely heavily on Ajax and JavaScript. I have a quick question about an issue we are running into and hopefully someone can provide an example solution :) We are trying to proof out a simple Ajax prototype using HTML unit. Basically it just submits an Ajax call and then uses innerHTML javascript to change a div value on the page. We would like to inspect the new value of this div. This is driven off a onclick even on an anchor tag. The problem is after the click event, when we inspect the div through HTMLUnit, it still contains the original value and not the new one. Below is our HTMLUnit code we are trying to use: final WebClient webClient = new WebClient(); final HtmlPage page = (HtmlPage) webClient.getPage("http://localhost:8080/test.jsp"); HtmlAnchor anchor = (HtmlAnchor) page.getAnchors().get(0); System.out.println(anchor.getOnClickAttribute()); page.executeJavaScript(anchor.getOnClickAttribute()); HtmlPage page2 = (HtmlPage) anchor.click(); HtmlElement he = page2.getHtmlElementById("testDiv"); The HTMLElement is the orininal value in this example. The sample jsp is attached if you would like to see exactly. I appreciate any help. Thanks! ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping |