From: <ddk...@ki...> - 2005-05-13 16:37:05
|
HtmlUnit is throwing an exception when it tries to run this JavaScript on the web page: window.onload=document.getElementById("PostingTitle").focus(); However, this code should NOT throw an exception--calling focus() on an INPUT field of type TEXT should work just fine. Looks like it might be a bug in HtmlUnit (or Rhino). I would recommend filing a bug on SourceForge for this issue. Having said that, if you wouldn't have gotten an exception loading that web page, then you would have next gotten an AssertionError thrown for the assertEquals() line since the title of the Craig's List page would not have matched "htmlunit - Welcome to HtmlUnit". Try a different URL to continue your testing. Dave On Fri, May 13, 2005 at 09:18:45AM -0700, John Tangney wrote: > Hi > > I just downloaded HTLMUnit and am trying the very first example in the > tutorial, like this: > > public class TestBug extends TestCase { > public void testHomePage() throws Exception { > final WebClient webClient = new WebClient(); > final URL url = new > URL("http://post.craigslist.org/sfo/R/res/eby/49"); > final HtmlPage page = (HtmlPage)webClient.getPage(url); > assertEquals( "htmlunit - Welcome to HtmlUnit", page.getTitleText() > ); > } > } > > but with a different URL: http://post.craigslist.org/sfo/R/res/eby/49 > > The example works with the original URL. > > I get an exception. Any hints? > Thx, > --johnt > > Testsuite: com.jdtangney.poster.TestBug > Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 10.552 sec > ------------- Standard Error ----------------- > May 13, 2005 9:13:34 AM org.apache.commons.httpclient.HttpMethodDirector > isRedirectNeeded > INFO: Redirect requested but followRedirects is disabled > ------------- ---------------- --------------- > > Testcase: testHomePage took 10.486 sec > Caused an ERROR > argument type mismatch > ======= EXCEPTION START ======== > Exception class=[com.gargoylesoftware.htmlunit.ScriptException] > com.gargoylesoftware.htmlunit.ScriptException: argument type mismatch > at > com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScript > Engine.java:293) > [...] > ======= EXCEPTION END ======== > == CALLING JAVASCRIPT == > window.onload=document.getElementById("PostingTitle").focus(); > ======= EXCEPTION END ======== > > > -- > JD Tangney and Associates > http://jdtangney.com > +1-510-579-2800 |