From: santhi v. <san...@ho...> - 2003-05-20 14:33:47
|
Hi, I am having problem with htmlunit when I submit a form. (View Source of the page containing this form is attached) The problems: 1. When I tried to set value as follows in the text field, I got the javascript exception (ScriptException: undefined is not a function). HtmlForm htmlform = page.getFormByName("myForm"); HtmlTextInput fileName = (HtmlTextInput)htmlform.getInputByName("file_name"); fileName.setValueAttribute("ffff"); System.out.println("fileName = " +fileName.getValueAttribute() ); (So I tried to disable the javacsript using webClient.setJavaScriptEnabled(false); before calling setValueAttribute() and that worked and getValueAttribute() showed that the value is set to "ffff") com.gargoylesoftware.htmlunit.ScriptException: undefined is not a function. at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:199) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:767) at com.gargoylesoftware.htmlunit.html.HtmlInput.setValueAttribute(HtmlInput.java:50) at com.interwoven.clientTest.TestLeo.bizUI_testCopyFile(TestLeo.java:311) at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22) at junit.extensions.TestSetup$1.protect(TestSetup.java:19) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.extensions.TestSetup.run(TestSetup.java:23) at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:325) at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:536) 2. Now I enabled the javascript webClient.setJavaScriptEnabled(true); abd then submit the form. htmlform.submit(); I get simillar Exception: <system-err><![CDATA[com.gargoylesoftware.htmlunit.ScriptException: undefined is not a function. at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:199) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:770) at com.gargoylesoftware.htmlunit.ScriptFilter.executeScript(ScriptFilter.java:188) at com.gargoylesoftware.htmlunit.ScriptFilter.endElement(ScriptFilter.java:165) at org.cyberneko.html.HTMLTagBalancer.endElement(Unknown Source) at org.cyberneko.html.HTMLScanner$SpecialScanner.scan(Unknown Source) at org.cyberneko.html.HTMLScanner.scanDocument(Unknown Source) at org.cyberneko.html.HTMLConfiguration.parse(Unknown Source) at org.cyberneko.html.HTMLConfiguration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.DOMParser.parse(Unknown Source) at com.gargoylesoftware.htmlunit.html.HtmlPage.createDocument(HtmlPage.java:250) at com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:129) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:322) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:242) at com.gargoylesoftware.htmlunit.html.HtmlForm.submit(HtmlForm.java:137) at com.gargoylesoftware.htmlunit.html.HtmlForm.submit(HtmlForm.java:88) at com.interwoven.clientTest.TestLeo.bizUI_testCopyFile(TestLeo.java:323) at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22) at junit.extensions.TestSetup$1.protect(TestSetup.java:19) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.extensions.TestSetup.run(TestSetup.java:23) at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:325) at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:536) Does anyone know/seen this before? Thanks, Santhi. _________________________________________________________________ Attention NRI! Send money home easily. http://server1.msn.co.in/msnleads/citibankrca/citibankrca2.asp Just sign up! |