From: Ahmed A. <asa...@ya...> - 2013-11-11 08:32:16
|
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/2013"); > 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 > > > > |