|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
HtmlUnit converts dom attribute type="Value" to type="value" (converts the value to lower case)Hi, I wanted to make you aware of this bug in HtmlUnit 2.6. The following html DOM element: <input name="Test1" type="Text" value="Test1" /> will appear in HtmlUnit as <input name="Test1" type="text" value="Test1" /> Notice that "Text" got changed to "text". As far as I know, this is happening only with the type="..." attributes. Because of this issue, my XPath search is not finding this DOM element. Below is a short java app. that reproduces the bug. I appreciate your contribution and thank you for the great free product! -Ivaylo package yada; import com.gargoylesoftware.htmlunit.BrowserVersion; import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.html.HtmlElement; import com.gargoylesoftware.htmlunit.html.HtmlPage; /** * This is a use case showing that HtmlUnit 2.6 converts * the value of node attribute "type" to lower case. * To run the test, save the simple html code below * into a file C:/Temp/test.html and run this main() method. <html> <head><title>Test</title></head> <body> <form name="test" action="."> <input name="Test1" type="Text" value="Test1" /> </form> </body> </html> * */ public class TestDomElemAttrCaseSensitivity { public static void main(String[] arghhhh) throws Exception { WebClient client = new WebClient(BrowserVersion.FIREFOX_3); HtmlPage page = client.getPage("file:///C:/Temp/test.html"); System.out.println(page.asXml()); { // XPATH search for //input[@type='Text'] returns null. final HtmlElement textInputElement = (HtmlElement) page.getFirstByXPath("//input[@type='Text']"); System.out.println(textInputElement); // prints null } { // XPATH search for //input[@type='text'] returns HtmlTextInput[<input name="Test1" type="text" value="Test1">]. final HtmlElement textInputElement = (HtmlElement) page.getFirstByXPath("//input[@type='text']"); System.out.println(textInputElement); // prints HtmlTextInput[<input name="Test1" type="text" value="Test1">] } } } ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Htmlunit-user mailing list Htmlunit-user@... https://lists.sourceforge.net/lists/listinfo/htmlunit-user |
|
|
Re: HtmlUnit converts dom attribute type="Value" to type="value" (converts the value to lower case)Hi,
I don't think that this is a bug. If you try to evaluate such an XPath in Firefox, you won't find any result either: HtmlUnit just normalize the value of the value attribute as done in Firefox. Cheers, Marc. Ivaylo Zlatev a écrit : > Hi, I wanted to make you aware of this bug in HtmlUnit 2.6. > The following html DOM element: > <input name="Test1" type="Text" value="Test1" /> > will appear in HtmlUnit as > <input name="Test1" type="text" value="Test1" /> > Notice that "Text" got changed to "text". > As far as I know, this is happening only with the type="..." attributes. > Because of this issue, my XPath search is not finding this DOM element. > Below is a short java app. that reproduces the bug. > > I appreciate your contribution and thank you for the great free product! > -Ivaylo > > package yada; > > import com.gargoylesoftware.htmlunit.BrowserVersion; > import com.gargoylesoftware.htmlunit.WebClient; > import com.gargoylesoftware.htmlunit.html.HtmlElement; > import com.gargoylesoftware.htmlunit.html.HtmlPage; > > /** > * This is a use case showing that HtmlUnit 2.6 converts > * the value of node attribute "type" to lower case. > * To run the test, save the simple html code below > * into a file C:/Temp/test.html and run this main() method. > <html> > <head><title>Test</title></head> > <body> > <form name="test" action="."> > <input name="Test1" type="Text" value="Test1" /> > </form> > </body> > </html> > * > */ > public class TestDomElemAttrCaseSensitivity { > > public static void main(String[] arghhhh) throws Exception { > WebClient client = new WebClient(BrowserVersion.FIREFOX_3); > > HtmlPage page = client.getPage("file:///C:/Temp/test.html"); > System.out.println(page.asXml()); > > { > // XPATH search for //input[@type='Text'] returns null. > final HtmlElement textInputElement = (HtmlElement) page.getFirstByXPath("//input[@type='Text']"); > System.out.println(textInputElement); // prints null > } > > { > // XPATH search for //input[@type='text'] returns HtmlTextInput[<input name="Test1" type="text" value="Test1">]. > final HtmlElement textInputElement = (HtmlElement) page.getFirstByXPath("//input[@type='text']"); > System.out.println(textInputElement); // prints HtmlTextInput[<input name="Test1" type="text" value="Test1">] > } > } > > } > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > Htmlunit-user mailing list > Htmlunit-user@... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Htmlunit-user mailing list Htmlunit-user@... https://lists.sourceforge.net/lists/listinfo/htmlunit-user |
|
|
|
|
|
|
|
|
Re: HtmlUnit converts dom attribute type="Value" to type="value" (converts the value to lower case)Hi,
I guess you've been testing with Firefox 3.5, whereas I was testing with Firefox 3.1. Following code gives different results in these browsers: <html><body> <input type="Text"> <script> var nb = document.evaluate("count(//input[@type = 'text'])", document, null, XPathResult.ANY_TYPE, null).numberValue; alert("with 'text': " + nb); nb = document.evaluate("count(//input[@type = 'Text'])", document, null, XPathResult.ANY_TYPE, null).numberValue; alert("with 'Text': " + nb); </script> </body></html> This being said, I think that: - JavaScript interpretation should behave like in browsers, meaning that HtmlUnit should respect case of type attribute as browser do. Please open an issue for that if it is important for you. - HtmlUnit's API should allow not to bother whether some of the attributes have been written with lower case and other with upper case: it would just make code less readable particularly as XPath 1 has no function to convert case. Cheers, Marc. Ivaylo Zlatev a écrit : > Marc, I tested it again in Firefox. > It is a bug in HtmlUnit. > Here are my test results: > > Firefox: > XPath search for //input[@type='Text'] : Finds it. > XPath search for //input[@type='text'] : Does not find it. > > HtmlUnit: > XPath search for //input[@type='Text'] : Does not find it. > XPath search for //input[@type='text'] : Finds it. > > As far as I know, HtmlUnit "normalizes" (converts to lower case) only the value in attribute type="...", whereas other attributes (e.g. name="...") are untouched. > Firefox does not normalize any attribute values. > > Thanks, > -Ivaylo > > > > > > > ----- Original Message ---- > Subject: Re: [Htmlunit-user] HtmlUnit converts dom attribute type="Value" to type="value" (converts the value to lower case) > > Hi, > > I don't think that this is a bug. If you try to evaluate such an XPath > in Firefox, you won't find any result either: HtmlUnit just normalize > the value of the value attribute as done in Firefox. > > Cheers, > Marc. > > Ivaylo Zlatev a écrit : >> Hi, I wanted to make you aware of this bug in HtmlUnit 2.6. >> The following html DOM element: >> <input name="Test1" type="Text" value="Test1" /> >> will appear in HtmlUnit as >> <input name="Test1" type="text" value="Test1" /> >> Notice that "Text" got changed to "text". >> As far as I know, this is happening only with the type="..." attributes. >> Because of this issue, my XPath search is not finding this DOM element. >> Below is a short java app. that reproduces the bug. >> >> I appreciate your contribution and thank you for the great free product! >> -Ivaylo >> >> package yada; >> >> import com.gargoylesoftware.htmlunit.BrowserVersion; >> import com.gargoylesoftware.htmlunit.WebClient; >> import com.gargoylesoftware.htmlunit.html.HtmlElement; >> import com.gargoylesoftware.htmlunit.html.HtmlPage; >> >> /** >> * This is a use case showing that HtmlUnit 2.6 converts >> * the value of node attribute "type" to lower case. >> * To run the test, save the simple html code below >> * into a file C:/Temp/test.html and run this main() method. >> <html> >> <head><title>Test</title></head> >> <body> >> <form name="test" action="."> >> <input name="Test1" type="Text" value="Test1" /> >> </form> >> </body> >> </html> >> * >> */ >> public class TestDomElemAttrCaseSensitivity { >> >> public static void main(String[] arghhhh) throws Exception { >> WebClient client = new WebClient(BrowserVersion.FIREFOX_3); >> >> HtmlPage page = client.getPage("file:///C:/Temp/test.html"); >> System.out.println(page.asXml()); >> >> { >> // XPATH search for //input[@type='Text'] returns null. >> final HtmlElement textInputElement = (HtmlElement) > page.getFirstByXPath("//input[@type='Text']"); >> System.out.println(textInputElement); // prints null >> } >> >> { >> // XPATH search for //input[@type='text'] returns HtmlTextInput[<input > name="Test1" type="text" value="Test1">]. >> final HtmlElement textInputElement = (HtmlElement) > page.getFirstByXPath("//input[@type='text']"); >> System.out.println(textInputElement); // prints HtmlTextInput[<input > name="Test1" type="text" value="Test1">] >> } >> } >> >> } >> >> ------------------------------------------------------------------------------ >> Come build with us! The BlackBerry(R) Developer Conference in SF, CA >> is the only developer event you need to attend this year. Jumpstart your >> developing skills, take BlackBerry mobile applications to market and stay >> ahead of the curve. Join us from November 9 - 12, 2009. Register now! >> http://p.sf.net/sfu/devconference >> _______________________________________________ >> Htmlunit-user mailing list >> Htmlunit-user@li... >> https://lists.sourceforge.net/lists/listinfo/htmlunit-user >> > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > Htmlunit-user mailing list > Htmlunit-user@... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Htmlunit-user mailing list Htmlunit-user@... https://lists.sourceforge.net/lists/listinfo/htmlunit-user |
| Free embeddable forum powered by Nabble | Forum Help |