From: Nitin T. <nt...@ne...> - 2013-11-20 08:47:05
|
Hi All, I am stuck in this. Not able to proceed. Any pointers will be really helpful, please tell me what can I do to make it work. Regards Nitin From: Ahmed Ashour [mailto:asa...@ya...] Sent: Monday, November 11, 2013 2:02 PM To: Nitin Tomer; htm...@li... Subject: Re: [Htmlunit-user] Not able to submit a form Hi Nitin, This is almost as my previous code. If you save the page to a local file and see its output in real browser, you will see it didn't get the 'from'/'to'/'date' fields correctly, as it says "you need to specify" them. I believe you need to know how the website detects values inside the <input> and use HtmlUnit accordingly. Ahmed _____ From: Nitin Tomer <nt...@ne...> To: Ahmed Ashour <asa...@ya...>; "htm...@li..." <htm...@li...> Sent: Sunday, November 10, 2013 8:34 PM Subject: Re: [Htmlunit-user] Not able to submit a form Hi Ahmed, I am doing it this way - HtmlForm form = (HtmlForm)searchPage.getElementById("flights-form"); if(form != null) { (form.getInputByName("MDCity_1")).setValueAttribute("Los Angeles, CA - Los Angeles Intl Airport (LAX)"); (form.getInputByName("MDCity_2")).setValueAttribute("New York City, NY - All Airports (NYC)"); (form.getInputByName("DepDateMD1")).setValueAttribute("11/15/2013"); HtmlButton searchButton = form.getElementById("air-btn-submit-retl"); searchResultPage = searchButton.click(); while(!searchResultPage.getUrl().toString().contains("airlines")) { System.out.println("Waiting!!"); Thread t = Thread.currentThread(); t.sleep(60 * 1000); searchResultPage = (HtmlPage)webClient.getCurrentWindow().getEnclosedPage(); System.out.println("Page Content: " + searchResultPage.asXml()); } It is printing a blank page every time, and is not taking me to the results page. Please suggest what I am doing wrong. Regards Nitin On Sunday, 10-11-2013 on 17:12 Ahmed Ashour wrote: Hi Nitin, How do you fill the form? The below doesn't work HtmlPage page = webClient.getPage("http://www.priceline.com/flights/"); page.<HtmlInput>getHtmlElementById("air-loc-from").setValueAttribute("Los Angeles, CA - Los Angeles Intl Airport (LAX)"); page.<HtmlInput>getHtmlElementById("air-loc-to").setValueAttribute("New York City, NY - All Airports (NYC)"); page.<HtmlInput>getHtmlElementById("return-date").setValueAttribute("12/01/2 013"); HtmlPage page2 = page.getHtmlElementById("air-submit-btn").click(); Ahmed _____ From: Nitin Tomer <nt...@ne...> To: htm...@li... Sent: Wednesday, November 6, 2013 4:39 PM Subject: [Htmlunit-user] Not able to submit a form Hi, I am trying to submit a form on this link - http://www.priceline.com/flights/ I am giving values - from (LAX), to (NYC) and date as 07-Nov-2013. It is giving me results when I do it by browser but returns the same page when I try this with HtmlUnit. I saw that the form had this tag - <form class="searchform" pclnform="1" fmproduct="flights" data-section="FlightsForm" Xaction="/qp.asp" method="POST"> The button tag is - <button id="air-submit-btn" class="button primary medium" type="submit" value="retl">Search Flights</button> Why is this form not being submitted? Is it because the form has an xaction instead of action? Please help. Regards Nitin Disclaimer :- This e-mail and any attachment may contain confidential, proprietary or legally privileged information. If you are not the original intended recipient and have erroneously received this message, you are prohibited from using, copying, altering or disclosing the content of this message. Please delete it immediately and notify the sender. Newgen Software Technologies Ltd (NSTL) accepts no responsibilities for loss or damage arising from the use of the information transmitted by this email including damages from virus and further acknowledges that no binding nature of the message shall be implied or assumed unless the sender does so expressly with due authority of NSTL. |