The pages I am trying to test uses ModalWindows when running the test as
InternetExplorer.
Therefor I have tried to change the JWebUnit code to simulate Firefox.
This seems to work but when I am running the following test 

public class DomTest extends TestCase {

  /**
   * @param name
   */
  public DomTest(String name) {
    super(name);
  }

  public void testTRSearchStatic() throws Exception 
  {
    WebTesterX t = new WebTesterX();
    t.getTestContext().setBaseUrl("file:///c:/");
    t.beginAt("/domenode.html");
    t.clickElementByXPath("//[EMAIL PROTECTED]'button' and @value='Wait']");
  }
}

On the page


<html>

  <head>
    <title>New Page 1</title>
  </head>
 
  <body>
    <script language="JavaScript" type="text/javascript">
      function performAction() {
        actionwindow =
window.open('','1205399746518','location=no,scrollbars=no,resizable=no,w
idth=200,height=275');
        actionwindow.document.writeln("Please wait while connecting to
server...");
        actionwindow.close();
      }
    </script>

    <input type=button onclick=performAction(); value=Wait>
  </body>
</html> 

I get the following exception

Exception class=[org.mozilla.javascript.WrappedException]
com.gargoylesoftware.htmlunit.ScriptException: Wrapped
java.lang.IllegalStateException: DomNode has not been set for this
SimpleScriptable: com.gargoylesoftware.htmlunit.javascript.host.Document
(script in file:/c:/hello.html from (6, 58) to (0, 0)#9)
        at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContex
tAction.run(JavaScriptEngine.java:557)
        at org.mozilla.javascript.Context.call(Context.java:564)
        at org.mozilla.javascript.Context.call(Context.java:499)
        at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(J
avaScriptEngine.java:470)
        at
com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfP
ossible(HtmlPage.java:751)
        at
com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.ex
ecuteEventHandler(EventListenersContainer.java:175)
        at
com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.ex
ecuteBubblingListeners(EventListenersContainer.java:188)
        at
com.gargoylesoftware.htmlunit.javascript.host.Node.fireEvent(Node.java:5
65)
        at
com.gargoylesoftware.htmlunit.html.HtmlElement$1.run(HtmlElement.java:12
10)
        at org.mozilla.javascript.Context.call(Context.java:577)
        at org.mozilla.javascript.Context.call(Context.java:499)
        at
com.gargoylesoftware.htmlunit.html.HtmlElement.fireEvent(HtmlElement.jav
a:1214)
        at
com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableEleme
nt.java:135)
        at
com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableEleme
nt.java:109)
        at
com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableEleme
nt.java:87)
        at
jwebunitext.HtmlUnitDialogX.clickElementByXPath(HtmlUnitDialogX.java:167
1)
        at
jwebunitext.WebTesterX.clickElementByXPath(WebTesterX.java:2043)
        at DomTest.testTRSearchStatic(DomTest.java:41)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at junit.framework.TestCase.runTest(TestCase.java:164)
        at junit.framework.TestCase.runBare(TestCase.java:130)
        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:120)
        at junit.framework.TestSuite.runTest(TestSuite.java:230)
        at junit.framework.TestSuite.run(TestSuite.java:225)
        at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUn
it3TestReference.java:130)
        at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.ja
va:38)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:460)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:673)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
ner.java:386)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
nner.java:196)
Caused by: org.mozilla.javascript.WrappedException: Wrapped
java.lang.IllegalStateException: DomNode has not been set for this
SimpleScriptable: com.gargoylesoftware.htmlunit.javascript.host.Document
(script in file:/c:/hello.html from (6, 58) to (0, 0)#9)
        at
org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1757)
        at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:170)
        at
org.mozilla.javascript.FunctionObject.call(FunctionObject.java:411)
        at
org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3237)
        at
org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2394)
        at
org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java
:162)
        at
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
        at
com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCal
l(HtmlUnitContextFactory.java:185)
        at
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
        at
org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java
:160)
        at
com.gargoylesoftware.htmlunit.javascript.host.EventHandler.call(EventHan
dler.java:99)
        at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(J
avaScriptEngine.java:499)
        at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$6.doRun(JavaSc
riptEngine.java:464)
        at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContex
tAction.run(JavaScriptEngine.java:553)
        ... 35 more
Caused by: java.lang.IllegalStateException: DomNode has not been set for
this SimpleScriptable:
com.gargoylesoftware.htmlunit.javascript.host.Document
        at
com.gargoylesoftware.htmlunit.javascript.SimpleScriptable.getDomNodeOrDi
e(SimpleScriptable.java:129)
        at
com.gargoylesoftware.htmlunit.javascript.host.Document.write(Document.ja
va:349)
        at
com.gargoylesoftware.htmlunit.javascript.host.Document.jsxFunction_write
ln(Document.java:304)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:155)
        ... 47 more
WrappedException: org.mozilla.javascript.WrappedException: Wrapped
java.lang.IllegalStateException: DomNode has not been set for this
SimpleScriptable: com.gargoylesoftware.htmlunit.javascript.host.Document
(script in file:/c:/hello.html from (6, 58) to (0, 0)#9)
        at
org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1757)
        at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:170)
        at
org.mozilla.javascript.FunctionObject.call(FunctionObject.java:411)
        at
org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3237)
        at script.performAction(script in file:/c:/hello.html from (6,
58) to (0, 0):9)
        at script(onclick event for HtmlButtonInput[<input type="button"
onclick="performAction();" value="Wait">]:1)
        at
org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2394)
        at
org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java
:162)
        at
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
        at
com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCal
l(HtmlUnitContextFactory.java:185)
        at
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
        at
org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java
:160)
        at
com.gargoylesoftware.htmlunit.javascript.host.EventHandler.call(EventHan
dler.java:99)
        at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(J
avaScriptEngine.java:499)
        at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$6.doRun(JavaSc
riptEngine.java:464)
        at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContex
tAction.run(JavaScriptEngine.java:553)
        at org.mozilla.javascript.Context.call(Context.java:564)
        at org.mozilla.javascript.Context.call(Context.java:499)
        at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(J
avaScriptEngine.java:470)
        at
com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfP
ossible(HtmlPage.java:751)
        at
com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.ex
ecuteEventHandler(EventListenersContainer.java:175)
        at
com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.ex
ecuteBubblingListeners(EventListenersContainer.java:188)
        at
com.gargoylesoftware.htmlunit.javascript.host.Node.fireEvent(Node.java:5
65)
        at
com.gargoylesoftware.htmlunit.html.HtmlElement$1.run(HtmlElement.java:12
10)
        at org.mozilla.javascript.Context.call(Context.java:577)
        at org.mozilla.javascript.Context.call(Context.java:499)
        at
com.gargoylesoftware.htmlunit.html.HtmlElement.fireEvent(HtmlElement.jav
a:1214)
        at
com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableEleme
nt.java:135)
        at
com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableEleme
nt.java:109)
        at
com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableEleme
nt.java:87)
        at
jwebunitext.HtmlUnitDialogX.clickElementByXPath(HtmlUnitDialogX.java:167
1)
        at
jwebunitext.WebTesterX.clickElementByXPath(WebTesterX.java:2043)
        at DomTest.testTRSearchStatic(DomTest.java:41)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at junit.framework.TestCase.runTest(TestCase.java:164)
        at junit.framework.TestCase.runBare(TestCase.java:130)
        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:120)
        at junit.framework.TestSuite.runTest(TestSuite.java:230)
        at junit.framework.TestSuite.run(TestSuite.java:225)
        at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUn
it3TestReference.java:130)
        at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.ja
va:38)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:460)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:673)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
ner.java:386)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
nner.java:196)
Caused by: java.lang.IllegalStateException: DomNode has not been set for
this SimpleScriptable:
com.gargoylesoftware.htmlunit.javascript.host.Document
        at
com.gargoylesoftware.htmlunit.javascript.SimpleScriptable.getDomNodeOrDi
e(SimpleScriptable.java:129)
        at
com.gargoylesoftware.htmlunit.javascript.host.Document.write(Document.ja
va:349)
        at
com.gargoylesoftware.htmlunit.javascript.host.Document.jsxFunction_write
ln(Document.java:304)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:155)
        ... 47 more
Inside wrapped exception:
java.lang.IllegalStateException: DomNode has not been set for this
SimpleScriptable: com.gargoylesoftware.htmlunit.javascript.host.Document
        at
com.gargoylesoftware.htmlunit.javascript.SimpleScriptable.getDomNodeOrDi
e(SimpleScriptable.java:129)
        at
com.gargoylesoftware.htmlunit.javascript.host.Document.write(Document.ja
va:349)
        at
com.gargoylesoftware.htmlunit.javascript.host.Document.jsxFunction_write
ln(Document.java:304)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:155)
        at
org.mozilla.javascript.FunctionObject.call(FunctionObject.java:411)
        at
org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3237)
        at
org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2394)
        at
org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java
:162)
        at
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
        at
com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCal
l(HtmlUnitContextFactory.java:185)
        at
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
        at
org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java
:160)
        at
com.gargoylesoftware.htmlunit.javascript.host.EventHandler.call(EventHan
dler.java:99)
        at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(J
avaScriptEngine.java:499)
        at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$6.doRun(JavaSc
riptEngine.java:464)
        at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContex
tAction.run(JavaScriptEngine.java:553)
        at org.mozilla.javascript.Context.call(Context.java:564)
        at org.mozilla.javascript.Context.call(Context.java:499)
        at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(J
avaScriptEngine.java:470)
        at
com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfP
ossible(HtmlPage.java:751)
        at
com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.ex
ecuteEventHandler(EventListenersContainer.java:175)
        at
com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.ex
ecuteBubblingListeners(EventListenersContainer.java:188)
        at
com.gargoylesoftware.htmlunit.javascript.host.Node.fireEvent(Node.java:5
65)
        at
com.gargoylesoftware.htmlunit.html.HtmlElement$1.run(HtmlElement.java:12
10)
        at org.mozilla.javascript.Context.call(Context.java:577)
        at org.mozilla.javascript.Context.call(Context.java:499)
        at
com.gargoylesoftware.htmlunit.html.HtmlElement.fireEvent(HtmlElement.jav
a:1214)
        at
com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableEleme
nt.java:135)
        at
com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableEleme
nt.java:109)
        at
com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableEleme
nt.java:87)
        at
jwebunitext.HtmlUnitDialogX.clickElementByXPath(HtmlUnitDialogX.java:167
1)
        at
jwebunitext.WebTesterX.clickElementByXPath(WebTesterX.java:2043)
        at DomTest.testTRSearchStatic(DomTest.java:41)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at junit.framework.TestCase.runTest(TestCase.java:164)
        at junit.framework.TestCase.runBare(TestCase.java:130)
        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:120)
        at junit.framework.TestSuite.runTest(TestSuite.java:230)
        at junit.framework.TestSuite.run(TestSuite.java:225)
        at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUn
it3TestReference.java:130)
        at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.ja
va:38)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:460)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:673)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
ner.java:386)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
nner.java:196)
== CALLING JAVASCRIPT ==
function () {
        [native code, arity=0]
}




Any one who knows where the problem can be?

I am using Jwebunit 1.4.1 and HtmlUnit 1.14.



Regards,
Michael Danielsson

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
JWebUnit-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-users

Reply via email to