2012-05-30

Submitting a form with HtmlUnit

HtmlUnit is not only nice for testing webpages, but also a slick way to control other peoples websites from code. However the "get started"-page is not entirely up-to-date: Fetching the submit-button actually differs a little.
 
//their version
final HtmlSubmitInput button = form.getInputByName("submitbutton");
// [...]
final HtmlPage page2 = button.click();

//what actually worked for me
final HtmlButton button = form.getButtonByName("submitbutton");
// [...]
final HtmlPage page2 = button.click();
Which version, you ask? I do not exactly know, for I used their Snapshot-Repository
 
        
            
                true
                always
            
            
                false
            
            HtmlUnitSnapshots
            HtmlUnit Snapshots
            http://htmlunit.sourceforge.net/m2-repo-snapshots
            default
        


No comments:

Post a Comment