diff options
Diffstat (limited to '')
-rw-r--r-- | sca-java-2.x/trunk/samples/store/pom.xml | 35 | ||||
-rw-r--r-- | sca-java-2.x/trunk/samples/store/src/test/java/store/StoreTestCase.java | 24 |
2 files changed, 25 insertions, 34 deletions
diff --git a/sca-java-2.x/trunk/samples/store/pom.xml b/sca-java-2.x/trunk/samples/store/pom.xml index d4b09c3ffb..a6d85eba2b 100644 --- a/sca-java-2.x/trunk/samples/store/pom.xml +++ b/sca-java-2.x/trunk/samples/store/pom.xml @@ -104,27 +104,20 @@ <scope>runtime</scope> </dependency> - <dependency> - <groupId>htmlunit</groupId> - <artifactId>htmlunit</artifactId> - <version>1.14</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>xerces</groupId> - <artifactId>xercesImpl</artifactId> - <version>2.8.1</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.8.1</version> - <scope>test</scope> - </dependency> - </dependencies> + <dependency> + <groupId>net.sourceforge.htmlunit</groupId> + <artifactId>htmlunit</artifactId> + <version>2.6</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.8.1</version> + <scope>test</scope> + </dependency> + </dependencies> <build> <finalName>${artifactId}</finalName> diff --git a/sca-java-2.x/trunk/samples/store/src/test/java/store/StoreTestCase.java b/sca-java-2.x/trunk/samples/store/src/test/java/store/StoreTestCase.java index 8c66e28427..900bc3f582 100644 --- a/sca-java-2.x/trunk/samples/store/src/test/java/store/StoreTestCase.java +++ b/sca-java-2.x/trunk/samples/store/src/test/java/store/StoreTestCase.java @@ -37,6 +37,7 @@ import client.Shopper; import com.gargoylesoftware.htmlunit.BrowserVersion; import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; +import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController; import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput; import com.gargoylesoftware.htmlunit.html.HtmlForm; @@ -90,27 +91,24 @@ public class StoreTestCase { @Test @Ignore public void testStoreWidget() throws FailingHttpStatusCodeException, MalformedURLException, IOException { - WebClient browser = new WebClient(BrowserVersion.FIREFOX_2); - browser.setRedirectEnabled(true); - browser.setThrowExceptionOnScriptError(false); + WebClient webClient = new WebClient(BrowserVersion.FIREFOX_3); + webClient.setRedirectEnabled(true); + webClient.setThrowExceptionOnScriptError(false); + webClient.waitForBackgroundJavaScript(50000); + webClient.waitForBackgroundJavaScriptStartingBefore(50000); + webClient.setAjaxController(new NicelyResynchronizingAjaxController()); - HtmlPage page = (HtmlPage) browser.getPage("http://localhost:8080/store/store.html"); - - //delay to allow all javascript to be retrieved and loaded - try { - Thread.sleep(8000); - } catch (InterruptedException e) { - e.printStackTrace(); - } + HtmlPage page = (HtmlPage) webClient.getPage("http://localhost:8080/store/store.html"); HtmlForm form = (HtmlForm) page.getFormByName("catalogForm"); HtmlCheckBoxInput catalogItems = (HtmlCheckBoxInput) form.getInputByName("items"); - System.out.println(">>>" + catalogItems.getAttributeValue("value")); - Assert.assertEquals("Apple - $2.99", catalogItems.getAttributeValue("value")); + System.out.println(">>>" + catalogItems.getAttribute("value")); + Assert.assertEquals("Apple - $2.99", catalogItems.getAttribute("value")); + webClient.closeAllWindows(); } } |