From: Bhupesh R. S. <bhu...@vi...> - 2005-04-19 09:47:05
|
Sorry I thought that getFrameset() is an inbuilt script function. That's why I've even put it as the same in the subject. Here is the getFrameset() method /** * function called to access frame elements=20 * */ function getFrameset(aFrame) { if (document.getElementById) { elm =3D parent.document.getElementById(aFrame); } else if (document.all) { elm =3D parent.frames[1].document.all[aFrame]; } else if (document.layers) { elm =3D parent.frames[1].document.layers[aFrame]; } return elm; } And calling getFrameset("bottom") is returning null. -----Original Message----- From: htm...@li... [mailto:htm...@li...] On Behalf Of Marc Guillemot Sent: Tuesday, April 19, 2005 3:07 PM To: htm...@li... Subject: Re: [Htmlunit-user] Urgent: JavaScript: getFrameset(""); returningnull Hi, welcome to hmlunit. The problem is that your js function getFrameset("bottom") returns null. I can't say more on it because you didn't provide its code. The next issue that may appears, is that property cols of the frameset js object isn't implemented now in htmlunit. But this could possibly work because it will be set as a normal dynamic property on the object. Please open a bug issue with this example and the code of your getFrameset function (reduced to the minimal is better). Concerning the log messages, see: http://htmlunit.sourceforge.net/faq.html#RedirectionDiagnosticMessages The "Expected content type of text/javascript but got [text/html]" means that your webserver sends javascript files with an incorrect content type. Marc. Bhupesh Reddy Sura wrote: > *I am migrating from HttpUnit to HtmlUnit. I am trying to login to my=20 > application from HtmlUnit.* > =20 > *Here is the test case.* > =20 > public void testHtmlUnit() throws IOException > { > WebClient wc =3D new WebClient(); > wc.setRedirectEnabled(true); > URL url =3D new URL("http://localhost:8080/abc/abc_frameset.jsp"); > HtmlPage page =3D (HtmlPage)wc.getPage(url); > =20 > HtmlForm form =3D page.getFormByName("mainForm"); > HtmlSubmitInput loginButton =3D=20 > (HtmlSubmitInput)form.getHtmlElementById("loginButton"); > HtmlTextInput username =3D (HtmlTextInput)=20 > form.getInputByName("j_username"); > HtmlPasswordInput password =3D (HtmlPasswordInput)=20 > form.getInputByName("j_password"); > username.setValueAttribute("zdpm_admin"); > password.setValueAttribute("zdpm_admin"); > HtmlPage page2 =3D (HtmlPage) loginButton.click(); > //System.out.println(page2.toString()); > =20 > } > =20 > *When I run it, I get the following exception.* > =20 > =3D=3D=3D=3D=3D=3D=3D EXCEPTION START =3D=3D=3D=3D=3D=3D=3D=3D > EcmaError: lineNumber=3D[148] column=3D[0] lineSource=3D[null]=20 > name=3D[TypeError] sourceName=3D[/abc/jscripts/navbar.js] > message=3D[TypeError: Cannot set property "cols" of null to "0,*"=20 > (/abc/jscripts/navbar.js#148)] > *com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot set=20 > property "cols" of null to "0,*" (/abc/jscripts/navbar.js#148)* at > com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction > (JavaScriptEngine.java:344) > at > com.gargoylesoftware.htmlunit.html.HtmlPage.executeOnLoadHandlersIfNee > ded(HtmlPage.java:953) > at > com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:1 > 58) > at > com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient. > java:701) at=20 > com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:361) > . > . > . > *The line 148 of navbar.js has the following code. hideLeftnav()=20 > method is called from the onLoad event.* > =20 > 146 function hideLeftnav() { > 147 var bottom =3D getFrameset("bottom") ; > 148 bottom.cols=3D"0,*"; > 149 } > =20 > *my frameset looks like this.* > =20 > <frameset id=3D"application" title=3D"Application" rows=3D"60,0,*" > framespacing=3D"0" frameborder=3D"1" > > <frame noresize id=3D"navbar" name=3D"navbar" src=3D"<%=3D navbar = %>" > marginwidth=3D"0" marginheight=3D"0" scrolling=3D"no" frameborder=3D"0"> > <frame noresize id=3D"subnavbar" name=3D"subnavbar" src=3D"subNavblank.jsp" > marginwidth=3D"0" marginheight=3D"0" scrolling=3D"no" frameborder=3D"0"> > *<frameset id=3D"bottom" title=3D"bottom" cols=3D"<%=3D bodysize = %>"=20 > framespacing=3D"0"> > * <frame class=3D"leftNav" id=3D"leftNav" name=3D"leftNav" = noresize=20 > src=3D"<%=3D leftnav %>" > marginwidth=3D"0" marginheight=3D"0" frameborder=3D"0"=20 > scrolling=3D"auto"> > <frame class=3D"workArea" id=3D"workarea" name=3D"workArea" > marginwidth=3D"0" marginheight=3D"0" > scrolling=3D"auto" frameborder=3D"0" src=3D"<%=3D = workarea %>"> > </frameset> > </frameset> > =20 > *Apparantly getFrameset("bottom"); is returning null. But when I run=20 > it from the browser (IE 6), it is working fine. It is working even=20 > from the HttpUnit test case. Can anyone explain why this is=20 > happening.* > ** > *also i am getting lot of warnings and info's on my console. some of=20 > them include* > ** > =20 > Apr 19, 2005 10:45:43 AM com.gargoylesoftware.htmlunit.html.HtmlPage > loadJavaScriptFromUrl > WARNING: Expected content type of text/javascript or=20 > application/x-javascript for remotely loaded javascript element=20 > http://localhost:8080/abc/errors/images/login.js > <http://localhost:8080/abc/errors/images/login.js> but got [text/html] > Apr 19, 2005 10:45:45 AM=20 > org.apache.commons.httpclient.HttpMethodDirector isRedirectNeeded > INFO: *Redirect requested but followRedirects is disabled* > =20 > *I have explicitly added webClient.setRedirectEnabled(true); in my code.=20 > but why i am still getting the *INFO: *Redirect requested but=20 > followRedirects is disabled.* > ** > *What does the warning *Expected content type of text/javascript but=20 > got [text/html] *means.* > ** > ** ------------------------------------------------------- This SF.Net email is sponsored by: New Crystal Reports XI. Version 11 adds new functionality designed to reduce time involved in creating, integrating, and deploying reporting solutions. Free runtime info, new features, or free trial, at: http://www.businessobjects.com/devxi/728 _______________________________________________ Htmlunit-user mailing list Htm...@li... https://lists.sourceforge.net/lists/listinfo/htmlunit-user |