From: <pas...@ya...> - 2004-02-17 15:10:24
|
Hi All, I'm a new user of htmlunit ressources and it's a beginner question. For example, I would like to load an first url, click on a button of it, collect the new page in a HtmlPage and submit the form of the second page. For moment, I load and click correctly the button of my first page and I don't receive the new html content of page in an HtmlPage object. example: /***************************************************/ java.net.URL url = new java.net.URL("http://local/test.html"); WebClient webClient = new WebClient() ; HtmlPage page = (HtmlPage) webClient.getPage(url); try { HtmlForm form = page.getFormByName( "DEBUT" ); HtmlButtonInput buttonInput = (HtmlButtonInput) form.getInputByName("Validate"); HtmlPage newpage = (HtmlPage)buttonInput.click(); logt("title of second page :"+newpage.getTitleText()) ; } catch(com.gargoylesoftware.htmlunit.ElementNotFoundException ex) { logt("Form non trouvée") ; } /***************************************************/ I think that it's a very simple problem but I don't find for moment. Can you help me on it ? Best Regards, Pascal. Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout ! Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/ |
From: Mike B. <mb...@Ga...> - 2004-02-18 12:16:55
|
pascal NICOLAS wrote: > For moment, I load and click correctly the button of > my first page and I don't receive the new html content > of page in an HtmlPage object. Can you be more specific about what *does* happen? Is an exception being thrown? Is the wrong page being returned? -- Mike Bowler Principal, Gargoyle Software Inc. Voice: (416) 822-0973 | Email : mb...@Ga... Fax : (416) 822-0975 | Website: http://www.GargoyleSoftware.com |
From: <pas...@ya...> - 2004-02-20 11:22:47
|
I tried to be more clear on my explanation. java.net.URL url = new java.net.URL("http://eluard/sasprod"); WebClient webClient = new WebClient() ; HtmlPage page = (HtmlPage) webClient.getPage(url); logt(page.toString()); try { java.util.List l = page.getAllForms() ; HtmlForm form = (HtmlForm)l.get(0) ; HtmlButtonInput buttonInput = (HtmlButtonInput) form.getInputByName("Valider"); HtmlPage secondpage = (HtmlPage)form.submit() ; logt("a => "+buttonInput.getOnClickAttribute()) ; logt(secondpage.toString()); logt(secondpage.getAllForms().toString()) ; logt("URL=> "+secondpage.getWebResponse().getUrl().toString()) ; } catch(com.gargoylesoftware.htmlunit.ElementNotFoundException ex) { logt("Form not found") ; } In this example, If I understood correctly. 1- I load the first page : http://eluard/sasprod (I verified, it's ok) 2- I collect the form of the first page (I verified, it's ok) 3- I click on the button (I don't know if it's ok) 4- I receive the new page in the object "secondpage". The problem appears with this new page. If I tested the url or I dump the content of this page, I receive the contents of my first page and not the contents of the second. I don't understand why. To explain what I want to do : load page 1 => simulate click => load result html page after my click => change forms value => submit the form of my second page => collect the third page => ../.. I hope that it's more clear. Pascal. Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout ! Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/ |
From: Mike B. <mb...@Ga...> - 2004-02-20 12:04:04
|
pascal NICOLAS wrote: > To explain what I want to do : > load page 1 => simulate click => load result html page > after my click => change forms value => submit the > form of my second page => collect the third page => > ../.. If the first page and the second page are the same physical object (ie page1 === page2) then there was some javascript executed during the click and the page didn't actually get sent to the server. If the two pages contain the same data but are different java objects then that means you made two requests to the server. Can you identify which one was the case here? -- Mike Bowler Principal, Gargoyle Software Inc. Voice: (416) 822-0973 | Email : mb...@Ga... Fax : (416) 822-0975 | Website: http://www.GargoyleSoftware.com |
From: <pas...@ya...> - 2004-02-20 14:04:42
|
Thanks Mike, It was the first case. I should execute javascript code before. It works as I want now. Thanks, Pascal. --- Mike Bowler <mb...@Ga...> a écrit : > pascal NICOLAS wrote: > > To explain what I want to do : > > load page 1 => simulate click => load result html > page > > after my click => change forms value => submit > the > > form of my second page => collect the third page > => > > ../.. > > If the first page and the second page are the same > physical object (ie > page1 === page2) then there was some javascript > executed during the > click and the page didn't actually get sent to the > server. > > If the two pages contain the same data but are > different java objects > then that means you made two requests to the server. > > Can you identify which one was the case here? > > -- > Mike Bowler > Principal, Gargoyle Software Inc. > Voice: (416) 822-0973 | Email : > mb...@Ga... > Fax : (416) 822-0975 | Website: > http://www.GargoyleSoftware.com > > > > ------------------------------------------------------- > SF.Net is sponsored by: Speed Start Your Linux Apps > Now. > Build and deploy apps & Web services for Linux with > a free DVD software kit from IBM. Click Now! > http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout ! Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/ |