From: Gael H. <gae...@ho...> - 2005-05-11 07:39:13
|
I believe HtmlUnit uses Tidy for cleaning Html pages, but is it possible to disable it ? Htmlunit doesn't succeed in finding a submint button because of the transformed web page. Tidy tranform this : <form> <table> <table> <input ... > </table> <form> </table> into this: <form> <table> </table> <form> <table> <input ... > </table> and so HtmlUnit doesn't find the input in the form. |
From: Marc G. <mgu...@ya...> - 2005-05-11 08:50:21
|
HtmlUnit uses NekoHtml to parse the received html in a well formed tree. It is absolutely not possible to disable it: how could the html be parsed? If you don't have the possibility to fix your incorrect html, you can implement your own WebConnection to change the received html code before it is parsed by htmlunit. Marc. Gael Harbonnier wrote: > I believe HtmlUnit uses Tidy for cleaning Html pages, but is it possible > to disable it ? > Htmlunit doesn't succeed in finding a submint button because of the > transformed web page. > Tidy tranform this : > > <form> > <table> > <table> > <input ... > > </table> > <form> > > </table> > > into this: > > <form> > <table> > </table> > <form> > > <table> > <input ... > > </table> > > and so HtmlUnit doesn't find the input in the form. > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by Oracle Space Sweepstakes > Want to be the first software developer in space? > Enter now for the Oracle Space Sweepstakes! > http://ads.osdn.com/?ad_id=7393&alloc_id=16281&op=click > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > |
From: Gael H. <gae...@ho...> - 2005-05-11 10:58:23
|
Ok I started to study the source code but I noticed that the html is well parsed when I call WebResponse rep = webClient.getWebConnection().getResponse(new WebRequestSettings(url)); System.out.println(rep.getContentAsString()); but when I want to click on my button the input isn't find and if I want to display a Xml representation of the form with asXml method, the code is incorrect. HtmlForm form = (HtmlForm)pageCourrante.getForms().get(numeroFormulaire); System.out.println( form.asXml() ); HtmlInput bouton = (HtmlInput)form.getInputByValue(texteBouton); pageCourrante = (HtmlPage)((HtmlInput)bouton).click(); what about the getForms method ? Gael >From: Marc Guillemot <mgu...@ya...> >Reply-To: htm...@li... >To: htm...@li... >Subject: Re: [Htmlunit-user] Disable Tidy >Date: Wed, 11 May 2005 10:52:26 +0200 > >HtmlUnit uses NekoHtml to parse the received html in a well formed tree. It >is absolutely not possible to disable it: how could the html be parsed? >If you don't have the possibility to fix your incorrect html, you can >implement your own WebConnection to change the received html code before it >is parsed by htmlunit. > >Marc. > >Gael Harbonnier wrote: >>I believe HtmlUnit uses Tidy for cleaning Html pages, but is it possible >>to disable it ? >>Htmlunit doesn't succeed in finding a submint button because of the >>transformed web page. >>Tidy tranform this : >> >><form> >> <table> >> <table> >> <input ... > >> </table> >><form> >> >> </table> >> >>into this: >> >><form> >> <table> >> </table> >><form> >> >><table> >> <input ... > >> </table> >> >>and so HtmlUnit doesn't find the input in the form. >> >> >> >> >>------------------------------------------------------- >>This SF.Net email is sponsored by Oracle Space Sweepstakes >>Want to be the first software developer in space? >>Enter now for the Oracle Space Sweepstakes! >>http://ads.osdn.com/?ad_id=7393&alloc_id=16281&op=click >>_______________________________________________ >>Htmlunit-user mailing list >>Htm...@li... >>https://lists.sourceforge.net/lists/listinfo/htmlunit-user >> > > > >------------------------------------------------------- >This SF.Net email is sponsored by Oracle Space Sweepstakes >Want to be the first software developer in space? >Enter now for the Oracle Space Sweepstakes! >http://ads.osdn.com/?ad_id=7393&alloc_id=16281&op=click >_______________________________________________ >Htmlunit-user mailing list >Htm...@li... >https://lists.sourceforge.net/lists/listinfo/htmlunit-user |
From: Mike B. <mb...@Ga...> - 2005-05-11 11:10:04
|
Gael Harbonnier wrote: > Ok I started to study the source code but I noticed that the html is > well parsed when I call > > WebResponse rep = webClient.getWebConnection().getResponse(new > WebRequestSettings(url)); > System.out.println(rep.getContentAsString()); I've never seen NekoHTML fail to parse legal html. The only time I've seen it get confused is when the html is really badly formed. What you get from asXml() is the DOM tree after NekoHTML has parsed it. If the elements you want aren't there then NekoHTML stripped them out. If you believe that the html is correct and that NekoHTML has a bug then either post some html samples here or send them to the author of NekoHTML - http://people.apache.org/~andyc/neko/doc/html/ An easy way to see if your html is legal is to run it through the W3C validator - http://validator.w3.org/ If NekoHtml can't parse the html then I'd almost guarentee that it won't pass the validator either. Hope this helps. -- Mike Bowler President, Gargoyle Software Inc. Website: http://www.GargoyleSoftware.com Weblog : http://www.SphericalImprovement.com/blogs/mbowler/ |
From: Sridhar R. <Sri...@Su...> - 2005-05-31 20:50:23
|
Hello, I have a text field with "onkeypress" event (javascript) defined. What I want to do is to enter the value to the field using setInputValue() and to trigger this onkeypress event. To do it manually, after entering the value, I would press <Enter> key. Using HtmlUnit, is there any way to activate this event ? Thanks Sridhar |
From: Marc G. <mgu...@ya...> - 2005-06-01 07:35:47
|
As far I know, the key events are not yet supported . Marc. PS: why was the subject of your email "Disable Tidy"? Sridhar Ranganathan wrote: > Hello, > > I have a text field with "onkeypress" event (javascript) defined. What I > want to do is to enter the value to the field using setInputValue() and > to trigger this onkeypress event. > > To do it manually, after entering the value, I would press <Enter> key. > Using HtmlUnit, is there any way to activate this event ? > > Thanks > Sridhar > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by Yahoo. > Introducing Yahoo! Search Developer Network - Create apps using Yahoo! > Search APIs Find out how you can build Yahoo! directly into your own > Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005 > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > |
From: Sridhar R. <Sri...@Su...> - 2005-08-18 22:15:43
|
Hi, Is there any way I can use HtmlUnit to right click on an Anchor (link) and launch a new tab or window ? Thanks Sridhar Mike Bowler wrote: > Gael Harbonnier wrote: > > >>Ok I started to study the source code but I noticed that the html is >>well parsed when I call >> >>WebResponse rep = webClient.getWebConnection().getResponse(new >>WebRequestSettings(url)); >>System.out.println(rep.getContentAsString()); > > > > I've never seen NekoHTML fail to parse legal html. The only time I've > seen it get confused is when the html is really badly formed. > > What you get from asXml() is the DOM tree after NekoHTML has parsed it. > If the elements you want aren't there then NekoHTML stripped them out. > If you believe that the html is correct and that NekoHTML has a bug then > either post some html samples here or send them to the author of > NekoHTML - http://people.apache.org/~andyc/neko/doc/html/ > > An easy way to see if your html is legal is to run it through the W3C > validator - http://validator.w3.org/ > > If NekoHtml can't parse the html then I'd almost guarentee that it won't > pass the validator either. > > Hope this helps. > -- Sridhar R |
From: SALL O. <osa...@ya...> - 2005-08-19 10:16:57
|
Hi, Sorry, but i think i have found a possible bug with getEnclosingFormOrDie, I try to click on an element which is really in a form but I got this message : testInputs(TestClick)java.lang.IllegalStateException: Element is not comtained within a form: HtmlSubmitInput[<input value="FIND" type="submit" class="btn" id="digiId79">] at com.gargoylesoftware.htmlunit.html.HtmlElement.getEnclosingFormOrDie(HtmlElement.java:327) at com.gargoylesoftware.htmlunit.html.HtmlSubmitInput.doClickAction(HtmlSubmitInput.java:77) at com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.java:120) at TestClick.testInputs(TestClick.java:22) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at TestClick.main(TestClick.java:26) Thanks for help The source test is : public class TestClick extends TestCase { public void testInputs() throws Exception{ String path=racinePath+"/Tests/data/htmlFiles/original.html"; URL url = new URL("file://"+path); WebClient webClient = new WebClient(BrowserVersion.INTERNET_EXPLORER_6_0); HtmlPage page = (HtmlPage)webClient.getPage(url); HtmlElement htmlElement = page.getHtmlElementById("digiId79"); String str = ((ClickableElement) htmlElement).click().getWebResponse().getUrl().toExternalForm(); } public static void main (String[] args) { junit.textui.TestRunner.run(new TestSuite(TestClick.class)); } } and the "Original.html" <HTML id="digiId0"> <HEAD id="digiId1"> <TR id="digiId69"> <TD align="center" id="digiId70"> <TABLE border="0" cellspacing="0" cellpadding="2" id="digiId71"> <TR id="digiId72"> <TD width="150" id="digiId73"> <FORM action="http://yahoo.com/" name="mfrm" id="digiId74"> <INPUT type="hidden" name="itag" value="ody" id="digiId75"> </TD> <TD align="center" id="digiId76"> <INPUT type="text" name="q" size="20" maxlength="800" value="" style="width:319px" id="digiId77"> </TD> <TD nowrap="" id="digiId78"> <INPUT type="submit" value="FIND" class="btn" id="digiId79"> </TD> </FORM> </TABLE> </TD> </TR> </HEAD> </BODY> </HTML> ___________________________________________________________________________ Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger Téléchargez cette version sur http://fr.messenger.yahoo.com |
From: Marc G. <mgu...@ya...> - 2005-08-19 10:23:43
|
your html is not valid (no body, then content inside head, ...) therefore it can't currently be correctly understood by htmlunit. Marc. SALL Ousmane wrote: > Hi, > Sorry, but i think i have found a possible bug with > getEnclosingFormOrDie, I try to click on an element > which is really in a form but I got this message : > testInputs(TestClick)java.lang.IllegalStateException: > Element is not comtained within a form: > HtmlSubmitInput[<input value="FIND" type="submit" > class="btn" id="digiId79">] > at > com.gargoylesoftware.htmlunit.html.HtmlElement.getEnclosingFormOrDie(HtmlElement.java:327) > at > com.gargoylesoftware.htmlunit.html.HtmlSubmitInput.doClickAction(HtmlSubmitInput.java:77) > at > com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.java:120) > at TestClick.testInputs(TestClick.java:22) > at > sun.reflect.NativeMethodAccessorImpl.invoke0(Native > Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at TestClick.main(TestClick.java:26) > > Thanks for help > The source test is : > public class TestClick extends TestCase { > public void testInputs() throws Exception{ > String > path=racinePath+"/Tests/data/htmlFiles/original.html"; > > > URL url = new URL("file://"+path); > WebClient webClient = new > WebClient(BrowserVersion.INTERNET_EXPLORER_6_0); > HtmlPage page = (HtmlPage)webClient.getPage(url); > HtmlElement htmlElement = > page.getHtmlElementById("digiId79"); > > String str = ((ClickableElement) > htmlElement).click().getWebResponse().getUrl().toExternalForm(); > > } > > public static void main (String[] args) { > junit.textui.TestRunner.run(new > TestSuite(TestClick.class)); > } > } > and the "Original.html" > <HTML id="digiId0"> > <HEAD id="digiId1"> > <TR id="digiId69"> > <TD align="center" id="digiId70"> > <TABLE border="0" cellspacing="0" cellpadding="2" > id="digiId71"> > <TR id="digiId72"> > <TD width="150" id="digiId73"> > <FORM action="http://yahoo.com/" name="mfrm" > id="digiId74"> > <INPUT type="hidden" name="itag" value="ody" > id="digiId75"> > </TD> > <TD align="center" id="digiId76"> > <INPUT type="text" name="q" size="20" > maxlength="800" value="" style="width:319px" > id="digiId77"> > </TD> > <TD nowrap="" id="digiId78"> > <INPUT type="submit" value="FIND" > class="btn" id="digiId79"> > </TD> > </FORM> > </TABLE> > </TD> > </TR> > </HEAD> > </BODY> > </HTML> > > > > > > > ___________________________________________________________________________ > Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger > Téléchargez cette version sur http://fr.messenger.yahoo.com > > > ------------------------------------------------------- > SF.Net email is Sponsored by the Better Software Conference & EXPO > September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices > Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA > Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > |
From: SALL O. <osa...@ya...> - 2005-08-19 12:36:28
|
Sorry, I was testing the web page of altavista http://www.altavista.com/ on subpitting the form but and I think the it's not well-formed. --- Marc Guillemot <mgu...@ya...> a écrit : > your html is not valid (no body, then content inside > head, ...) therefore it can't currently be correctly > understood by > htmlunit. > > Marc. > > SALL Ousmane wrote: > > Hi, > > Sorry, but i think i have found a possible bug > with > > getEnclosingFormOrDie, I try to click on an > element > > which is really in a form but I got this message : > > > testInputs(TestClick)java.lang.IllegalStateException: > > Element is not comtained within a form: > > HtmlSubmitInput[<input value="FIND" type="submit" > > class="btn" id="digiId79">] > > at > > > com.gargoylesoftware.htmlunit.html.HtmlElement.getEnclosingFormOrDie(HtmlElement.java:327) > > at > > > com.gargoylesoftware.htmlunit.html.HtmlSubmitInput.doClickAction(HtmlSubmitInput.java:77) > > at > > > com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.java:120) > > at TestClick.testInputs(TestClick.java:22) > > at > > > sun.reflect.NativeMethodAccessorImpl.invoke0(Native > > Method) > > at > > > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > > at > > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > > at TestClick.main(TestClick.java:26) > > > > Thanks for help > > The source test is : > > public class TestClick extends TestCase { > > public void testInputs() throws Exception{ > > String > > > path=racinePath+"/Tests/data/htmlFiles/original.html"; > > > > > > URL url = new URL("file://"+path); > > WebClient webClient = new > > WebClient(BrowserVersion.INTERNET_EXPLORER_6_0); > > HtmlPage page = > (HtmlPage)webClient.getPage(url); > > HtmlElement htmlElement = > > page.getHtmlElementById("digiId79"); > > > > String str = ((ClickableElement) > > > htmlElement).click().getWebResponse().getUrl().toExternalForm(); > > > > } > > > > public static void main (String[] args) { > > junit.textui.TestRunner.run(new > > TestSuite(TestClick.class)); > > } > > } > > and the "Original.html" > > <HTML id="digiId0"> > > <HEAD id="digiId1"> > > <TR id="digiId69"> > > <TD align="center" id="digiId70"> > > <TABLE border="0" cellspacing="0" > cellpadding="2" > > id="digiId71"> > > <TR id="digiId72"> > > <TD width="150" id="digiId73"> > > <FORM action="http://yahoo.com/" > name="mfrm" > > id="digiId74"> > > <INPUT type="hidden" name="itag" > value="ody" > > id="digiId75"> > > </TD> > > <TD align="center" id="digiId76"> > > <INPUT type="text" name="q" size="20" > > maxlength="800" value="" style="width:319px" > > id="digiId77"> > > </TD> > > <TD nowrap="" id="digiId78"> > > <INPUT type="submit" value="FIND" > > class="btn" id="digiId79"> > > </TD> > > </FORM> > > </TABLE> > > </TD> > > </TR> > > </HEAD> > > </BODY> > > </HTML> > > > > > > > > > > > > > > > ___________________________________________________________________________ > > > Appel audio GRATUIT partout dans le monde avec le > nouveau Yahoo! Messenger > > Téléchargez cette version sur > http://fr.messenger.yahoo.com > > > > > > > ------------------------------------------------------- > > SF.Net email is Sponsored by the Better Software > Conference & EXPO > > September 19-22, 2005 * San Francisco, CA * > Development Lifecycle Practices > > Agile & Plan-Driven Development * Managing > Projects & Teams * Testing & QA > > Security * Process Improvement & Measurement * > http://www.sqe.com/bsce5sf > > _______________________________________________ > > Htmlunit-user mailing list > > Htm...@li... > > > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > > > > > > ------------------------------------------------------- > SF.Net email is Sponsored by the Better Software > Conference & EXPO > September 19-22, 2005 * San Francisco, CA * > Development Lifecycle Practices > Agile & Plan-Driven Development * Managing Projects > & Teams * Testing & QA > Security * Process Improvement & Measurement * > http://www.sqe.com/bsce5sf > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > ___________________________________________________________________________ Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger Téléchargez cette version sur http://fr.messenger.yahoo.com |