From: Marc G. <mgu...@ya...> - 2005-04-19 09:35:39
|
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 > application from HtmlUnit.* > > *Here is the test case.* > > public void testHtmlUnit() throws IOException > { > WebClient wc = new WebClient(); > wc.setRedirectEnabled(true); > URL url = new URL("http://localhost:8080/abc/abc_frameset.jsp"); > HtmlPage page = (HtmlPage)wc.getPage(url); > > HtmlForm form = page.getFormByName("mainForm"); > HtmlSubmitInput loginButton = > (HtmlSubmitInput)form.getHtmlElementById("loginButton"); > HtmlTextInput username = (HtmlTextInput) > form.getInputByName("j_username"); > HtmlPasswordInput password = (HtmlPasswordInput) > form.getInputByName("j_password"); > username.setValueAttribute("zdpm_admin"); > password.setValueAttribute("zdpm_admin"); > HtmlPage page2 = (HtmlPage) loginButton.click(); > //System.out.println(page2.toString()); > > } > > *When I run it, I get the following exception.* > > ======= EXCEPTION START ======== > EcmaError: lineNumber=[148] column=[0] lineSource=[null] > name=[TypeError] sourceName=[/abc/jscripts/navbar.js] > message=[TypeError: Cannot set property "cols" of null to "0,*" > (/abc/jscripts/navbar.js#148)] > *com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot set > 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.executeOnLoadHandlersIfNeeded(HtmlPage.java:953) > at > com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:158) > at > com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:701) > at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:361) > . > . > . > *The line 148 of navbar.js has the following code. hideLeftnav() method > is called from the onLoad event.* > > 146 function hideLeftnav() { > 147 var bottom = getFrameset("bottom") ; > 148 bottom.cols="0,*"; > 149 } > > *my frameset looks like this.* > > <frameset id="application" title="Application" rows="60,0,*" > framespacing="0" frameborder="1" > > <frame noresize id="navbar" name="navbar" src="<%= navbar %>" > marginwidth="0" marginheight="0" scrolling="no" frameborder="0"> > <frame noresize id="subnavbar" name="subnavbar" src="subNavblank.jsp" > marginwidth="0" marginheight="0" scrolling="no" frameborder="0"> > *<frameset id="bottom" title="bottom" cols="<%= bodysize %>" > framespacing="0"> > * <frame class="leftNav" id="leftNav" name="leftNav" noresize > src="<%= leftnav %>" > marginwidth="0" marginheight="0" frameborder="0" > scrolling="auto"> > <frame class="workArea" id="workarea" name="workArea" > marginwidth="0" marginheight="0" > scrolling="auto" frameborder="0" src="<%= workarea %>"> > </frameset> > </frameset> > > *Apparantly getFrameset("bottom"); is returning null. But when I run it > from the browser (IE 6), it is working fine. It is working even from the > HttpUnit test case. Can anyone explain why this is happening.* > ** > *also i am getting lot of warnings and info's on my console. some of > them include* > ** > > Apr 19, 2005 10:45:43 AM com.gargoylesoftware.htmlunit.html.HtmlPage > loadJavaScriptFromUrl > WARNING: Expected content type of text/javascript or > application/x-javascript for remotely loaded javascript element > 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 > org.apache.commons.httpclient.HttpMethodDirector isRedirectNeeded > INFO: *Redirect requested but followRedirects is disabled* > > *I have explicitly added webClient.setRedirectEnabled(true); in my code. > but why i am still getting the *INFO: *Redirect requested but > followRedirects is disabled.* > ** > *What does the warning *Expected content type of text/javascript but got > [text/html] *means.* > ** > ** |