From: Jim L. <jli...@ad...> - 2004-03-19 18:55:19
|
I'm an HtmlUnit newbie, completely. Definitely excited about the potential of HtmlUnit, as we are using JUnit quite successfully, and Silk is being used by QA. We need web-level testing controlled and regularly run by our programmers, and I'm hoping that HtmlUnit will do the trick. =20 BTW, another guy here was messing with Cactus, but found it difficult to use. I don't know many details, but are people on this list using Cactus successfully, or have you found it a pain in the neck? =20 Anyway, I found that just getting started was a little harder than expected. First, there was no complete file, just fragments. It was not clear which URL class was to be used (Eclipse found org.apache.catalina.util.URL and java.util.URL). It wasn't clear if we should extend TestCase or womething else. Then, when I ran the fragment, I got the ScriptException - fortunately, I found the fix several months into the archive. And finally, the title on the page had changed, so the test didn't work. =20 Does anyone know why I can't run javascript from the page? Is it the google ads again, as in the October '03 thread? Or something I am doing wrong, like only using the minimally required jars? =20 Finally, I think it would be helpful to post an entire minimal file that people could use to get started. Here is one: =20 // Change the package for your development environment package com.advisorsoftware.webtier.htmlunit; =20 =20 import java.net.URL; =20 import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.html.HtmlPage; =20 import junit.framework.TestCase; =20 /** * @author jlindsay * The purpose of this class is to get HtmlUnit running. Note that you must=20 * have the set of HtmlUnit required jars in your classpath, along with junit.jar, * for this to work. */ public class TestHtmlUnit extends TestCase { public void testHomePage()=20 throws Exception=20 { final WebClient webClient =3D new WebClient(); final URL url =3D new = URL("http://htmlunit.sourceforge.net"); =20 webClient.setJavaScriptEnabled(false); final HtmlPage page =3D (HtmlPage)webClient.getPage(url); =20 assertEquals( "htmlunit - Welcome to HtmlUnit", page.getTitleText()); } } =20 =20 |
From: Brad C. <bc...@bo...> - 2004-03-19 19:25:18
|
At 12:55 PM 3/19/2004, you wrote: >Im an HtmlUnit newbie, completely. Definitely excited about the potential >of HtmlUnit, as we are using JUnit quite successfully, and Silk is being >used by QA. We need web-level testing controlled and regularly run by our >programmers, and Im hoping that HtmlUnit will do the trick. That's exactly what we're using it for (though I let CruiseControl run it for me) >Anyway, I found that just getting started was a little harder than >expected. First, there was no complete file, just fragments. There are some tests in com.gargoylesoftware.htmlunit.SanityCheck. Not exactly obvious though... >It was not clear which URL class was to be used (Eclipse found >org.apache.catalina.util.URL and java.util.URL). org.apache.catalina.util.URL doesn't look like it's part of HtmlUnit so I don't think there's a lot we can do for you here. The compiler should complain if you use the wrong one though ;) >Then, when I ran the fragment, I got the ScriptException fortunately, I >found the fix several months into the archive. What was the fix? Is it something that should be on the web pages? >And finally, the title on the page had changed, so the test didnt work. I've updated the title in CVS so it will be fixed the next time the site is generated. Thanks for the heads up :) >Does anyone know why I cant run javascript from the page? Is it the >google ads again, as in the October 03 thread? Or something I am doing >wrong, like only using the minimally required jars? It seems to work fine with the code in CVS. Try the nightly build and see if that helps (another thing that will be on the web site next time it gets generated): http://htmlunit.sourceforge.net/nightly/ Brad C |
From: Mike B. <mb...@Ga...> - 2004-03-19 20:06:24
|
Brad Clarke wrote: > I've updated the title in CVS so it will be fixed the next time the site > is generated. Thanks for the heads up :) I've regenerated the site. There are 33 failing tests for some reason but I don't have time to dig into that right now - hopefully on the weekend. -- Mike Bowler Principal, Gargoyle Software Inc. Voice: (416) 822-0973 | Email : mb...@Ga... Fax : (416) 822-0975 | Website: http://www.GargoyleSoftware.com |