1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
final HtmlPage page1 = webClient.getPage("http://url-site-distant");
// Get the form that we are dealing with and within that form,
// find the submit button and the field that we want to change.
List form0 = page1.getForms();
Iterator j = form0.iterator();
HtmlForm element = (HtmlForm) j.next();
while (j.hasNext() && !(element.getId().equals("MiniConnexion")))
{
element = (HtmlForm) j.next();
}
final HtmlForm form = (HtmlForm)element;
final HtmlSubmitInput button = form.getInputByName("mini-submit");
final HtmlTextInput login = form.getInputByName("mini-login");
final HtmlTextInput pass = form.getInputByName("mini-pass");
login.setValueAttribute("mail");
pass.setValueAttribute("mdp");
// Now submit the form by clicking the button and get back the second page. <TITLE>Contact</TITLE>
HtmlPage page2 = button.click(); |