[Typo3-dev] htmlunit - users?

dan frost dan at danfrost.co.uk
Thu Jun 23 10:56:40 CEST 2005


htmlunit.sourceforge.net

It's a java library for accessing webpages "like" 
a user - e.g.

public void testHomePage() throws Exception {
     final WebClient webClient = new WebClient();
     final URL url = new 
URL("http://htmlunit.sourceforge.net");

     // Get the first page
     final HtmlPage page1 = 
(HtmlPage)webClient.getPage(url);

     // Get the form that we are dealing with and 
within that form,
     // find the submit button and the field that 
we want to change.
     final HtmlForm form = 
page1.getFormByName("myform");
     final HtmlSubmitInput button
     	= 
(HtmlSubmitInput)form.getInputByName("submitbutton");
     final HtmlTextInput textField
     	= (HtmlTextInput)form.getInputByName("userid");

     // Change the value of the text field
     textField.setValueAttribute("root");

     // Now submit the form by clicking the button 
and get back the
     // second page.
     final HtmlPage page2 = (HtmlPage)button.click();
}

...would test a form (taken from 
http://htmlunit.sourceforge.net/gettingStarted.html)

It isn't a unit-testing framework, as such, but is 
meant to be used with JUnit or similar to
run tests automatically on web-applications / 
web-sites.

dan

Martin Kutschker wrote:
> "dan frost" <dan at danfrost.co.uk> schrieb im Newsbeitrag 
> news:mailman.1.1119510921.21505.typo3-dev at lists.netfielders.de...
> 
>>Does anyone use htmlunit for testing TYPO3 apps/sites?
> 
> 
> What is it and where can I get it?
> 
> Masi 
> 
> 




More information about the TYPO3-dev mailing list