Hi Priya,

Thank you for this very clear bug reporting. It seems the problem come from the 
name of your Javascript function (onload). Try to rename it, and it should work.
It is certainly a bug in HtmlUnit, and I will report it.

++

Julien

----- Message d'origine ----
De : Krishnapriya Gelli <[EMAIL PROTECTED]>
À : [email protected]
Envoyé le : Mercredi, 6 Décembre 2006, 1h10mn 21s
Objet : [Jwebunit-users] Exception 
class=[org.mozilla.javascript.EvaluatorException]

Hello,
   
  I am new to jwebunit, can somebody help me understand why I am getting this 
exception:
   
  1) testLogin(com.LI.test.LiSampleTest)======= EXCEPTION START ========
  Exception class=[org.mozilla.javascript.EvaluatorException]
  com.gargoylesoftware.htmlunit.ScriptException: Property onload not found.
  at 
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:256)
  at 
com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:698)
  at 
com.gargoylesoftware.htmlunit.html.HtmlScript.appendChild(HtmlScript.java:187)
  at 
com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.handleCharacters(HTMLParser.java:418)
  at 
com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:379)
  at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
  at org.cyberneko.html.filters.DefaultFilter.endElement(DefaultFilter.java:249)
  at 
org.cyberneko.html.filters.NamespaceBinder.endElement(NamespaceBinder.java:367)
  at 
org.cyberneko.html.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1015)
  at org.cyberneko.html.HTMLTagBalancer.endElement(HTMLTagBalancer.java:888)
  at org.cyberneko.html.HTMLScanner$SpecialScanner.scan(HTMLScanner.java:2831)
  at org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:809)
  at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:478)
  at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:431)
  at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
  at
 
com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:312)
  at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:226)
  at 
com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:112)
  at 
com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:85)
  at 
com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:431)
  at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:335)
  at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:389)
  at 
net.sourceforge.jwebunit.htmlunit.HtmlUnitDialog.beginAt(HtmlUnitDialog.java:153)
  at net.sourceforge.jwebunit.junit.WebTester.beginAt(WebTester.java:170)
  at net.sourceforge.jwebunit.junit.WebTestCase.beginAt(WebTestCase.java:115)
  at com.LI.test.LiSampleTest.testLogin(LiSampleTest.java:26)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at
 sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  at net.sourceforge.jwebunit.junit.WebTestCase.runBare(WebTestCase.java:47)
  at com.LI.test.LiSampleTest.main(LiSampleTest.java:16)
  Caused by: org.mozilla.javascript.EvaluatorException: Property onload not 
found.
  at 
com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter.runtimeError(StrictErrorReporter.java:114)
  at org.mozilla.javascript.Context.reportRuntimeError(Context.java:966)
  at
 org.mozilla.javascript.Context.reportRuntimeError(Context.java:1022)
  at org.mozilla.javascript.Context.reportRuntimeError1(Context.java:985)
  at 
org.mozilla.javascript.ScriptableObject.setAttributes(ScriptableObject.java:416)
  at 
org.mozilla.javascript.ScriptableObject.defineProperty(ScriptableObject.java:1001)
  at 
org.mozilla.javascript.ScriptableObject.defineProperty(ScriptableObject.java:1019)
  at org.mozilla.javascript.ScriptRuntime.initFunction(ScriptRuntime.java:3034)
  at
 org.mozilla.javascript.Interpreter.initFunction(Interpreter.java:2225)
  at org.mozilla.javascript.Interpreter.initFrame(Interpreter.java:3743)
  at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2247)
  at 
org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:149)
  at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:337)
  at 
com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:151)
  at
 org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2755)
  at 
org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:160)
  at org.mozilla.javascript.Context.evaluateString(Context.java:1132)
  at 
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:252)
  ... 42 more
  Enclosed exception: 
  org.mozilla.javascript.EvaluatorException: Property onload not found.
  at 
com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter.runtimeError(StrictErrorReporter.java:114)
  at org.mozilla.javascript.Context.reportRuntimeError(Context.java:966)
  at org.mozilla.javascript.Context.reportRuntimeError(Context.java:1022)
  at org.mozilla.javascript.Context.reportRuntimeError1(Context.java:985)
  at 
org.mozilla.javascript.ScriptableObject.setAttributes(ScriptableObject.java:416)
  at 
org.mozilla.javascript.ScriptableObject.defineProperty(ScriptableObject.java:1001)
  at 
org.mozilla.javascript.ScriptableObject.defineProperty(ScriptableObject.java:1019)
  at org.mozilla.javascript.ScriptRuntime.initFunction(ScriptRuntime.java:3034)
  at org.mozilla.javascript.Interpreter.initFunction(Interpreter.java:2225)
  at org.mozilla.javascript.Interpreter.initFrame(Interpreter.java:3743)
  at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2247)
  at 
org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:149)
  at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:337)
  at 
com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:151)
  at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2755)
  at 
org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:160)
  at org.mozilla.javascript.Context.evaluateString(Context.java:1132)
  at 
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:252)
  at
 
com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:698)
  at 
com.gargoylesoftware.htmlunit.html.HtmlScript.appendChild(HtmlScript.java:187)
  at 
com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.handleCharacters(HTMLParser.java:418)
  at 
com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:379)
  at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
  at org.cyberneko.html.filters.DefaultFilter.endElement(DefaultFilter.java:249)
  at
 org.cyberneko.html.filters.NamespaceBinder.endElement(NamespaceBinder.java:367)
  at 
org.cyberneko.html.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1015)
  at org.cyberneko.html.HTMLTagBalancer.endElement(HTMLTagBalancer.java:888)
  at org.cyberneko.html.HTMLScanner$SpecialScanner.scan(HTMLScanner.java:2831)
  at org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:809)
  at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:478)
  at
 org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:431)
  at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
  at 
com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:312)
  at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:226)
  at 
com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:112)
  at 
com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:85)
  at
 com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:431)
  at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:335)
  at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:389)
  at 
net.sourceforge.jwebunit.htmlunit.HtmlUnitDialog.beginAt(HtmlUnitDialog.java:153)
  at net.sourceforge.jwebunit.junit.WebTester.beginAt(WebTester.java:170)
  at net.sourceforge.jwebunit.junit.WebTestCase.beginAt(WebTestCase.java:115)
  at
 com.LI.test.LiSampleTest.testLogin(LiSampleTest.java:26)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  at net.sourceforge.jwebunit.junit.WebTestCase.runBare(WebTestCase.java:47)
  at com.LI.test.LiSampleTest.main(LiSampleTest.java:16)
  == CALLING JAVASCRIPT ==
  function onload(){
  document.login.username.size = 20;
  
  document.login.username.focus();
  if (navigator.userAgent.indexOf('Windows NT 5.1') >0) {
  document.login.password.size = 22;
  } else {
  document.login.password.size = 20;
  }
  }
  ======= EXCEPTION END ========
  
  FAILURES!!!
  Tests run: 1, Failures: 0, Errors: 1
   
   
   
  The page I am trying to access:
  
<html>
<head>
<title>Insight Login</title>
<script>
function onload(){
   document.login.username.size = 20;
   
   document.login.username.focus();
   if (navigator.userAgent.indexOf('Windows NT 5.1') >0) {
      document.login.password.size = 22;
   } else {
     
 document.login.password.size = 20;
   }
}
</script>
</head>
   
  <br><br><br>
<body   bgcolor="#FFFFFF" onload="onload()">
<table width="80%" height="370" border="0" align="center">
  <tr> 
    <td height="247" width="23%">&nbsp;</td>
    <td height="247" width="53%">
      <div align="center">
        <img src="/insight/share/images/lucida-header-logo.jpg" width="177" 
height="143">
      </div>
    </td> 
    <td height="247" width="24%" bordercolor="#FFFFFF">&nbsp;</td>
  </tr>
  <tr> 
    <td height="123" width="23%">&nbsp;</td>
    <td
 height="123" width="53%"> 
   
          <form name="login" action="/insight/main/execute/login" method="POST">
      <table border="0" align="center">
        <tr> 
          <td>Username:</td>
          <td> 
            <input type="text" name="username" value="">
          </td>
        </tr>
        <tr> 
          <td>Password:</td>
          <td>
 
            <input type="password" name="password">
          </td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td> 
            <div align="center">
              <input type="hidden" name="locale" value="US"></input>
              <input type="submit" name="Submit2" value="Login">
            </div>
         
 </td>
        </tr>
      </table>
        </form>
    </td>
    <td height="123" width="24%">&nbsp;</td>
  </tr>
  <tr> 
    <td height="43" width="23%">&nbsp;</td>
    <td height="43" width="53%"> 
      <p align="center">&nbsp; </p>
    </td>
    <td height="43" width="24%">&nbsp;</td>
  </tr>
</table>
  <!-- 
    This file is intended be included in various login.jsp only.
-->
   
  </body>
</html>
   
  The code used:
   
  public class LiSampleTest extends WebTestCase {
  
  private PrintStream log;
  
  public static void main(String[] args) {
  junit.textui.TestRunner.run(new TestSuite(LiSampleTest.class));
  
  }
  
  public void setUp() {
  getTestContext().setBaseUrl("http://texas:8042/insight/main/en/";);
  
  }
  
  public void testLogin() throws FileNotFoundException, 
UnsupportedEncodingException {
  beginAt("login.jsp");
  assertFormPresent("login");
  assertFormElementPresent("username");

  assertFormElementPresent("password");
  setTextField("username", "insight");
  setTextField("password", "lucida1");
  submit("Submit2");
  log=new PrintStream(new FileOutputStream("login.txt"),true,"UTF-8");
 
 dumpHtml(log);
  //assertLinkPresentWithText(searchLink);
  //clickLinkWithText(searchLink);
  log.close();
  }
  
  
  
  
  
  
  }
   
   
  I tried to turn off the javascript, still I get the exception.
   
  Thank you,
  Priya
   
 


Everyone is raving about the all-new Yahoo! Mail 
beta.-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Jwebunit-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-users







        

        
                
___________________________________________________________________________ 
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! 
Profitez des connaissances, des opinions et des expériences des internautes sur 
Yahoo! Questions/Réponses 
http://fr.answers.yahoo.com
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Jwebunit-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-users

Reply via email to