From: <mbr...@vi...> - 2004-03-22 16:29:26
|
Hello again. I have been away from the HtmlUnit seen for some months now. I am now back at writing a test suite for a ASP.NET application. Things have changed since I last used HtmlUnit. I downloaded the latest sources from CVS and found that much of my old code doesn't compile anymore. In particular, the method HtmlPage.getOneHtmlElementByAttribute() is gone. What is it's replacement? I see some classes with "xpath" in their name. Does HtmlUnit now have xpath support? I'm sorry if this is a FAQ, but I didn't find anything in the list archive. I also found that I had to download maven and add the following jars to the classpath to get the source to compile using JBuilder. commons-jelly-20030902.160215.jar commons-jelly-tags-ant-20030625.032346.jar commons-jelly-tags-define-20030211.142932.jar commons-jelly-tags-util-20030211.141939.jar commons-jexl-1.0-beta-1.jar dom4j-1.4-dev-8.jar One last thing, which is also an issue with 1.2.3, is that HtmlImageInput.click () does not cause the enclosing form to get posted. I had to call HtmlImageInput.click(0,0). Is this by design? Thank you very much for your ongoing efforts! Mike Bresnahan |
From: Brad C. <bc...@bo...> - 2004-03-22 22:07:33
|
At 10:29 AM 3/22/2004, mbr...@vi... wrote: >Hello again. I have been away from the HtmlUnit seen for some months now. I >am now back at writing a test suite for a ASP.NET application. Things have >changed since I last used HtmlUnit. I downloaded the latest sources from CVS >and found that much of my old code doesn't compile anymore. In >particular, the >method HtmlPage.getOneHtmlElementByAttribute() is gone. What is it's >replacement? Some of HtmlPage's functionality was moved due to some DOM changes (I don't understand most of it myself). If you can't find something that used to be on HtmlPage look under HtmlPage.getDocumentElement(). Your method is: HtmlPage.getDocumentElement().getOneHtmlElementByAttribute(...) >I see some classes with "xpath" in their name. Does HtmlUnit now >have xpath support? I'm sorry if this is a FAQ, but I didn't find >anything in >the list archive. Yes it does. Here's an example (for you and the archive :p): final HtmlUnitXPath xpath = new HtmlUnitXPath(xpathExpression); HtmlElement element = (HtmlElement) xpath.selectSingleNode(currentHtmlPage); >I also found that I had to download maven and add the following jars to the >classpath to get the source to compile using JBuilder. >... I never did...all the jelly stuff just fails for me. One of these days I might add it to the ant build.xml, but I think I'd rather see good maven support in Eclipse :) >One last thing, which is also an issue with 1.2.3, is that >HtmlImageInput.click >() does not cause the enclosing form to get posted. I had to call >HtmlImageInput.click(0,0). Is this by design? The code looks like it will submit either way now. Try the nightly build and log a bug if it doesn't. >I have not had time to create a nice test case, but I have found that in >general HtmlUnit cannot deal with ASP.NET Validators (e.g. >System.Web.UI.WebControls.CompareValidator). HtmlUnit blows up in the >JavaScript produced by ASP.NET. Try the nightly build first, but if that doesn't help can you provide more information about the javascript? I don't have an ASP.NET project to play with. Brad C |
From: <mbr...@vi...> - 2004-03-23 16:30:52
|
After some research I believe the Validation controls are IE specific and are supposed to be disabled when using any other browser (typical Microsoft tactic). I tested this with Netscape 7.1 and found that yes indeed the validation controls are disabled. So my current thoery is that ASP.NET thinks that HtmlUnit is an IE compliant browser. I remember there being a way of configuring the browser identity of HtmlUnit. Perhaps that will fix the problem. Mike Bresnahan Quoting Brad Clarke <bc...@bo...>: > At 10:29 AM 3/22/2004, mbr...@vi... wrote: > >Hello again. I have been away from the HtmlUnit seen for some months now. > I > >am now back at writing a test suite for a ASP.NET application. Things have > >changed since I last used HtmlUnit. I downloaded the latest sources from > CVS > >and found that much of my old code doesn't compile anymore. In > >particular, the > >method HtmlPage.getOneHtmlElementByAttribute() is gone. What is it's > >replacement? > > Some of HtmlPage's functionality was moved due to some DOM changes (I don't > understand most of it myself). If you can't find something that used to be > on HtmlPage look under HtmlPage.getDocumentElement(). Your method is: > > > HtmlPage.getDocumentElement().getOneHtmlElementByAttribute(...) > > >I see some classes with "xpath" in their name. Does HtmlUnit now > >have xpath support? I'm sorry if this is a FAQ, but I didn't find > >anything in > >the list archive. > > Yes it does. Here's an example (for you and the archive :p): > > final HtmlUnitXPath xpath = new > HtmlUnitXPath(xpathExpression); > HtmlElement element = (HtmlElement) > xpath.selectSingleNode(currentHtmlPage); > > >I also found that I had to download maven and add the following jars to the > >classpath to get the source to compile using JBuilder. > >... > > I never did...all the jelly stuff just fails for me. One of these days I > might add it to the ant build.xml, but I think I'd rather see good maven > support in Eclipse :) > > >One last thing, which is also an issue with 1.2.3, is that > >HtmlImageInput.click > >() does not cause the enclosing form to get posted. I had to call > >HtmlImageInput.click(0,0). Is this by design? > > The code looks like it will submit either way now. Try the nightly build > and log a bug if it doesn't. > > >I have not had time to create a nice test case, but I have found that in > >general HtmlUnit cannot deal with ASP.NET Validators (e.g. > >System.Web.UI.WebControls.CompareValidator). HtmlUnit blows up in the > >JavaScript produced by ASP.NET. > > Try the nightly build first, but if that doesn't help can you provide more > information about the javascript? I don't have an ASP.NET project to play > with. > > Brad C |
From: Mike B. <mb...@Ga...> - 2004-03-23 17:01:16
|
mbr...@vi... wrote: > So my current thoery is that ASP.NET thinks > that HtmlUnit is an IE compliant browser. Yes. By default, HtmlUnit pretends to be IE. > I remember there being a way of > configuring the browser identity of HtmlUnit. new WebClient( BrowserVersion.MOZILLA_1_0 ) Or create your own BrowserVersion instance with the appropriate values. -- Mike Bowler Principal, Gargoyle Software Inc. Voice: (416) 822-0973 | Email : mb...@Ga... Fax : (416) 822-0975 | Website: http://www.GargoyleSoftware.com |
From: <mbr...@vi...> - 2004-03-23 20:35:46
|
> new WebClient( BrowserVersion.MOZILLA_1_0 ) That fixed it. Thanks! Of course I am still unable to test the validators, but that is probably a whole new project. Mike Bresnahan |