I'm using HTMLUnit for get a page on a web. In this webpage, there is a form. When i'm loading from Chrome and view source : something like this :
<form name="form" method="post" onsubmit="return checkDate();">
<input name="check_in_date" id="check_in_date" readonly="readonly" type="text" class="hasDatepicker"/>
<input name="check_out_date" id="check_out_date" readonly="readonly" type="text" class="hasDatepicker"/>
<input name="check_availability" value="test condition" type="submit"/>
</form>
But when I'm loading by using HTMLUnit by this code:
String url = "sample link";
WebClient webClient = new WebClient();
webClient.getOptions().setJavaScriptEnabled(true);
webClient.getOptions().setCssEnabled(false);
webClient.setAjaxController(new NicelyResynchronizingAjaxController());
HtmlPage page = webClient.getPage(url);
System.out.println(page.asXML());
I get different HTML Code. More detail :
<form name="form" method="post" onsubmit="return checkDate();">
<input name="check_in_date" id="check_in_date" readonly="readonly" type="text" class="hasDatepicker"/>
<input name="check_out_date" id="check_out_date" readonly="readonly" type="text" class="hasDatepicker"/>
<input name="check_availability" value="test condition" type="text"/>
</form>
The different here is : last line : <input name="check_availability" value="test condition" type="text"/>
Type now text, instead of submit, so I cannot this kind of code:
HtmlForm form = page.getFormByName("form");
HtmlSubmitInput submit = form.getInputByName("check_availability"); // error at this line
page = submit.click();
Error because now, this field is not a button
anymore, it's just a text`. I don't know why there's this difference. Please tell me how to fix this.
Thanks :)