Error while invoking HTMLSelect's getOptionByValue("somestr").setSelected(true)
kiransri Nov 6, 2010 4:17 PMPlease excuse for the long post. I am trying to resolve this issue unsuccessfully for the past 4 days and any help will be greatly appreciated.
I am testing a JSF page with jsf HTML and richfaces controls (calendar,editor,fileattachment,suggestion).
An error is being thrown when I try to set option value of a HTMLSelect in the page.
Error thrown is
TypeError: Cannot call method "save" of null (http://127.0.0.1:7101/nyuoaaapp/faces/a4j/g/3_3_1.GAscripts/editor.js#6)
EcmaError: lineNumber=[6] column=[0] lineSource=[null] name=[TypeError] sourceName=[http://127.0.0.1:7101/nyuoaaapp/faces/a4j/g/3_3_1.GAscripts/editor.js] message=[TypeError: Cannot call method "save" of null (http://127.0.0.1:7101/nyuoaaapp/faces/a4j/g/3_3_1.GAscripts/editor.js#6)]
com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot call method "save" of null (http://127.0.0.1:7101/nyuoaaapp/faces/a4j/g/3_3_1.GAscripts/editor.js#6)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:601)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:537)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:538)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:531)
at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:906)
at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeEventHandler(EventListenersContainer.java:197)
at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeBubblingListeners(EventListenersContainer.java:216)
at com.gargoylesoftware.htmlunit.javascript.host.Node.fireEvent(Node.java:686)
at com.gargoylesoftware.htmlunit.html.HtmlElement$2.run(HtmlElement.java:885)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:537)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:538)
at com.gargoylesoftware.htmlunit.html.HtmlElement.fireEvent(HtmlElement.java:890)
at com.gargoylesoftware.htmlunit.html.HtmlElement.fireEvent(HtmlElement.java:865)
at com.gargoylesoftware.htmlunit.html.HtmlInput.executeOnChangeHandlerIfAppropriate(HtmlInput.java:469)
at com.gargoylesoftware.htmlunit.html.HtmlSelect.setSelectedAttribute(HtmlSelect.java:310)
at com.gargoylesoftware.htmlunit.html.HtmlSelect.setSelectedAttribute(HtmlSelect.java:283)
at com.gargoylesoftware.htmlunit.html.HtmlOption.setSelected(HtmlOption.java:87)
at edu.nyu.ecoms.oaa.vs.test.web.VisitingScholarNewRequestTest.testSaveAsDraft(VisitingScholarNewRequestTest.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.apache.cactus.internal.AbstractCactusTestCase.runBareServer(AbstractCactusTestCase.java:153)
at org.apache.cactus.internal.server.AbstractWebTestCaller.doTest(AbstractWebTestCaller.java:119)
at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody0(AbstractWebTestController.java:93)
at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody1$advice(AbstractWebTestController.java:224)
at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest(AbstractWebTestController.java)
at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody2(ServletTestRedirector.java:101)
at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody3$advice(ServletTestRedirector.java:224)
at org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.java)
at org.jboss.jsfunit.framework.JSFUnitServletRedirector.doPost(JSFUnitServletRedirector.java:46)
at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody0(ServletTestRedirector.java:72)
at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody1$advice(ServletTestRedirector.java:224)
at org.apache.cactus.server.ServletTestRedirector.doGet(ServletTestRedirector.java)
at org.jboss.jsfunit.framework.JSFUnitServletRedirector.doGet(JSFUnitServletRedirector.java:52)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at org.jboss.jsfunit.framework.JSFUnitFilter.doFilter(JSFUnitFilter.java:119)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Caused by: net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: Cannot call method "save" of null (http://127.0.0.1:7101/nyuoaaapp/faces/a4j/g/3_3_1.GAscripts/editor.js#6)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3772)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3750)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3778)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3797)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.undefCallError(ScriptRuntime.java:3816)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2320)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2313)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1515)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:845)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:429)
at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:269)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3162)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
at com.gargoylesoftware.htmlunit.javascript.host.EventHandler.call(EventHandler.java:82)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:559)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$4.doRun(JavaScriptEngine.java:524)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:595)
... 55 more
Enclosed exception:
net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: Cannot call method "save" of null (http://127.0.0.1:7101/nyuoaaapp/faces/a4j/g/3_3_1.GAscripts/editor.js#6)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3772)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3750)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3778)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3797)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.undefCallError(ScriptRuntime.java:3816)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2320)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2313)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1515)
at script(http://127.0.0.1:7101/nyuoaaapp/faces/a4j/g/3_3_1.GAscripts/editor.js:6)
at script(http://127.0.0.1:7101/nyuoaaapp/faces/a4j/g/3_3_1.GAorg.ajax4jsf.javascript.PrototypeScript:17)
at script(http://127.0.0.1:7101/nyuoaaapp/faces/a4j/g/3_3_1.GAorg.ajax4jsf.javascript.AjaxScript:156)
at script(http://127.0.0.1:7101/nyuoaaapp/faces/a4j/g/3_3_1.GAorg.ajax4jsf.javascript.AjaxScript:159)
at script(onchange event for HtmlSelect[<select id="pinfnamePrefixValue" name="pinfnamePrefixValue" size="1" onchange="A4J.AJAX.Submit('_viewRoot','j_id4',event,{'control':this,'oncomplete':function(request,event,data){showErrorMessage()},'similarityGroupingId':'j_id161','parameters':{'ajaxSingle':'pinfnamePrefixValue','j_id161':'j_id161'} ,'actionUrl':'/nyuoaaapp/faces/cardrequestcreate.xhtml'} )">] in http://127.0.0.1:7101/nyuoaaapp/faces/cardrequestcreate.xhtml)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:845)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:429)
at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:269)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3162)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
at com.gargoylesoftware.htmlunit.javascript.host.EventHandler.call(EventHandler.java:82)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:559)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$4.doRun(JavaScriptEngine.java:524)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:595)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:537)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:538)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:531)
at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:906)
at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeEventHandler(EventListenersContainer.java:197)
at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeBubblingListeners(EventListenersContainer.java:216)
at com.gargoylesoftware.htmlunit.javascript.host.Node.fireEvent(Node.java:686)
at com.gargoylesoftware.htmlunit.html.HtmlElement$2.run(HtmlElement.java:885)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:537)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:538)
at com.gargoylesoftware.htmlunit.html.HtmlElement.fireEvent(HtmlElement.java:890)
at com.gargoylesoftware.htmlunit.html.HtmlElement.fireEvent(HtmlElement.java:865)
at com.gargoylesoftware.htmlunit.html.HtmlInput.executeOnChangeHandlerIfAppropriate(HtmlInput.java:469)
at com.gargoylesoftware.htmlunit.html.HtmlSelect.setSelectedAttribute(HtmlSelect.java:310)
at com.gargoylesoftware.htmlunit.html.HtmlSelect.setSelectedAttribute(HtmlSelect.java:283)
at com.gargoylesoftware.htmlunit.html.HtmlOption.setSelected(HtmlOption.java:87)
at edu.nyu.ecoms.oaa.vs.test.web.VisitingScholarNewRequestTest.testSaveAsDraft(VisitingScholarNewRequestTest.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.apache.cactus.internal.AbstractCactusTestCase.runBareServer(AbstractCactusTestCase.java:153)
at org.apache.cactus.internal.server.AbstractWebTestCaller.doTest(AbstractWebTestCaller.java:119)
at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody0(AbstractWebTestController.java:93)
at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody1$advice(AbstractWebTestController.java:224)
at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest(AbstractWebTestController.java)
at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody2(ServletTestRedirector.java:101)
at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody3$advice(ServletTestRedirector.java:224)
at org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.java)
at org.jboss.jsfunit.framework.JSFUnitServletRedirector.doPost(JSFUnitServletRedirector.java:46)
at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody0(ServletTestRedirector.java:72)
at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody1$advice(ServletTestRedirector.java:224)
at org.apache.cactus.server.ServletTestRedirector.doGet(ServletTestRedirector.java)
at org.jboss.jsfunit.framework.JSFUnitServletRedirector.doGet(JSFUnitServletRedirector.java:52)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at org.jboss.jsfunit.framework.JSFUnitFilter.doFilter(JSFUnitFilter.java:119)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
== CALLING JAVASCRIPT ==
function () {
[native code, arity=0]
}
======= EXCEPTION END ========
Error logs
I am seeing the following error in the console logs (repeated several times)
SEVERE: runtimeError: message=[The data necessary to complete this operation is not yet available.] sourceName=[http://127.0.0.1:7101/nyuoaaapp/faces/a4j/g/3_3_1.GAorg/richfaces/renderkit/html/scripts/jquery/jquery.js] line=[309] lineSource=[null] lineOffset=[0]
Nov 6, 2010 4:03:15 PM com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter runtimeError
The JSFUnit test code is as follows
JSFSession jsfSession;
JSFClientSession client;
JSFServerSession server;
public static Test suite() {
return new TestSuite( VisitingScholarNewRequestTest.class );
}
protected void setUp() throws ServletException,IOException {
jsfSession = new JSFSession("/JSFUnitEntryServlet?netid=KS2316");
// A JSFClientSession emulates the browser and lets you test HTML
client = jsfSession.getJSFClientSession();
// A JSFServerSession gives you access to JSF state
server = jsfSession.getJSFServerSession();
}
public void testSaveAsDraft() throws ServletException,IOException {
// Test navigation to initial viewID
assertEquals("/welcome.xhtml", server.getCurrentViewID());
client.click("link00");//Navigate to New request page.First link is link00
// Test navigation to initial viewID
assertEquals("/cardrequestcreate.xhtml", server.getCurrentViewID());
//Test the data loaded
// Test a managed bean
assertEquals(Constants.VS_ACTIONCD_CREATE, server.getManagedBeanValue("#{visitingScholar.actionCode}"));
HtmlSelect namePrefixSelect = (HtmlSelect)client.getElement("pinfnamePrefixValue");
namePrefixSelect.getOptionByValue("DR").setSelected(true);
HtmlSelect requestTypeSelect = (HtmlSelect)client.getElement("requestTypeValue");
requestTypeSelect.getOptionByValue("VSVS").setSelected(true); -- It is failing here and I have to still set several other values in the page..
}
Please help in resolving the issue. Any help would be greatly appreciated.
Regards
Kiran