Revision: 488
Author:   henryju
Date:     2006-06-21 02:27:06 -0700 (Wed, 21 Jun 2006)
ViewCVS:  http://svn.sourceforge.net/jwebunit/?rev=488&view=rev

Log Message:
-----------
Add gotoWindow(int windowID) and assertWindowCountEquals(int value), thanks to 
a suggestion from Buhi Mume.
Implement closeWindow() in htmlunit and httpunit plugin.
Add related test cases.

Modified Paths:
--------------
    
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FramesAndWindowsTest.java
    
trunk/jwebunit-commons-tests/src/main/resources/testcases/FramesAndWindowsTest/RootPage.html
    
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/IJWebUnitDialog.java
    trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/WebTestCase.java
    trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/WebTester.java
    
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitDialog.java
    
trunk/jwebunit-httpunit-plugin/src/main/java/net/sourceforge/jwebunit/httpunit/HttpUnitDialog.java
    
trunk/jwebunit-jacobie-plugin/src/main/java/net/sourceforge/jwebunit/jacobie/JacobieDialog.java
    
trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumDialog.java

Added Paths:
-----------
    
trunk/jwebunit-commons-tests/src/main/resources/testcases/FramesAndWindowsTest/ChildPage3.html
Modified: 
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FramesAndWindowsTest.java
===================================================================
--- 
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FramesAndWindowsTest.java
 2006-06-21 09:21:32 UTC (rev 487)
+++ 
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FramesAndWindowsTest.java
 2006-06-21 09:27:06 UTC (rev 488)
@@ -52,12 +52,17 @@
     }   
 
     public void testGotoWindow() {
-        beginAt("RootPage.html");
         gotoRootAndOpenChild("ChildPage1");
         gotoWindow("ChildPage1");
         assertTextPresent("child 1");
     }
     
+    public void testGotoWindowByID() {
+        gotoRootAndOpenChild("ChildPage3");
+        gotoWindow(1);
+        assertTextPresent("child 3");
+    }
+
     public void testGotoWindowByTitle() {
         gotoRootAndOpenChild("ChildPage2");
         gotoWindowByTitle("Child Page 2");
@@ -76,6 +81,27 @@
         assertTextPresent("This is the Root");
     }
 
+    public void testCloseWindow() {
+        beginAt("RootPage.html");
+        assertTitleEquals("This is the Root");
+        clickLink("ChildPage1");
+        gotoWindow("ChildPage1");
+        assertTextPresent("child 1");
+        closeWindow();
+        assertWindowCountEquals(1);
+        assertTitleEquals("This is the Root");
+    }
+
+    public void testAssertWindowCountEquals() {
+        beginAt("RootPage.html");
+        assertWindowCountEquals(1);
+        clickLink("ChildPage1");
+        assertWindowCountEquals(2);
+        gotoWindow("ChildPage1");
+        closeWindow();
+        assertWindowCountEquals(1);
+    }
+
     // ----------- frames test --------------
 
     public void testGotoFrame() {

Added: 
trunk/jwebunit-commons-tests/src/main/resources/testcases/FramesAndWindowsTest/ChildPage3.html
===================================================================
--- 
trunk/jwebunit-commons-tests/src/main/resources/testcases/FramesAndWindowsTest/ChildPage3.html
                              (rev 0)
+++ 
trunk/jwebunit-commons-tests/src/main/resources/testcases/FramesAndWindowsTest/ChildPage3.html
      2006-06-21 09:27:06 UTC (rev 488)
@@ -0,0 +1,8 @@
+<html>
+       <head>
+               <title></title>
+       </head>
+       <body>
+               This is child 3
+       </body>
+</html>

Modified: 
trunk/jwebunit-commons-tests/src/main/resources/testcases/FramesAndWindowsTest/RootPage.html
===================================================================
--- 
trunk/jwebunit-commons-tests/src/main/resources/testcases/FramesAndWindowsTest/RootPage.html
        2006-06-21 09:21:32 UTC (rev 487)
+++ 
trunk/jwebunit-commons-tests/src/main/resources/testcases/FramesAndWindowsTest/RootPage.html
        2006-06-21 09:27:06 UTC (rev 488)
@@ -8,5 +8,6 @@
                </form>
                        <a id="ChildPage1" href="javascript:void(0)" 
onClick="javascript:window.open('ChildPage1.html', 'ChildPage1', 'width=650', 
true)">Child Page 1</a>
                        <a id="ChildPage2" href="javascript:void(0)" 
onClick="javascript:window.open('ChildPage2.html', 'ChildPage2')">Child Page 
2</a>
+                       <a id="ChildPage3" href="ChildPage3.html" 
target="_blank">Child Page 3</a>
        </body>
 </html>
\ No newline at end of file

Modified: 
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/IJWebUnitDialog.java
===================================================================
--- 
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/IJWebUnitDialog.java 
    2006-06-21 09:21:32 UTC (rev 487)
+++ 
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/IJWebUnitDialog.java 
    2006-06-21 09:27:06 UTC (rev 488)
@@ -94,23 +94,35 @@
     /**
      * Make the window with the given name active.
      * 
-     * @param windowName
+     * @param windowName Name of the window
      */
     void gotoWindow(String windowName);
 
     /**
      * Goto first window with the given title.
      * 
-     * @param windowName
+     * @param title Title of the window
      */
     void gotoWindowByTitle(String title);
 
     /**
+     * Goto window with the given Javascript ID.
+     * 
+     * @param windowID Javascript ID of the window
+     */
+    void gotoWindow(int windowID);
+
+    /**
      * Make the root window active.
      */
     void gotoRootWindow();
 
     /**
+     * Get the number of openend Windows.
+     */
+    int getWindowCount();
+
+    /**
      * Close the current window.
      * 
      */

Modified: 
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/WebTestCase.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/WebTestCase.java 
2006-06-21 09:21:32 UTC (rev 487)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/WebTestCase.java 
2006-06-21 09:27:06 UTC (rev 488)
@@ -99,6 +99,10 @@
         getTester().closeBrowser();
     }
 
+    public void closeWindow() {
+        getTester().closeWindow();
+    }
+
     public String getMessage(String key) {
         return getTester().getMessage(key);
     }
@@ -553,10 +557,18 @@
         getTester().assertWindowPresent(windowName);
     }
 
+    public void assertWindowPresent(int windowID) {
+        getTester().assertWindowPresent(windowID);
+    }
+
     public void assertWindowPresentWithTitle(String title) {
         getTester().assertWindowPresentWithTitle(title);
     }
 
+    public void assertWindowCountEquals(int windowCount) {
+        getTester().assertWindowCountEquals(windowCount);
+    }
+
     public void assertFramePresent(String frameName) {
         getTester().assertFramePresent(frameName);
     }
@@ -790,6 +802,10 @@
         getTester().gotoWindow(windowName);
     }
 
+    public void gotoWindow(int windowID) {
+        getTester().gotoWindow(windowID);
+    }
+
     public void gotoFrame(String frameName) {
         getTester().gotoFrame(frameName);
     }

Modified: 
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/WebTester.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/WebTester.java   
2006-06-21 09:21:32 UTC (rev 487)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/WebTester.java   
2006-06-21 09:27:06 UTC (rev 488)
@@ -66,8 +66,8 @@
         String theTestingEngineKey = getTestingEngineKey();
         Class theClass;
         try {
-            theClass = TestingEngineRegistry.getTestingEngineClass(
-                    theTestingEngineKey);
+            theClass = TestingEngineRegistry
+                    .getTestingEngineClass(theTestingEngineKey);
         } catch (ClassNotFoundException e1) {
             throw new RuntimeException(e1);
         }
@@ -101,6 +101,13 @@
         }
     }
 
+    /**
+     * Close the current window
+     */
+    public void closeWindow() {
+        getDialog().closeWindow();
+    }
+
     public void setDialog(IJWebUnitDialog aIJWebUnitDialog) {
         dialog = aIJWebUnitDialog;
     }
@@ -326,8 +333,8 @@
     public void assertTextInTable(String tableSummaryNameOrId, String text) {
         assertTablePresent(tableSummaryNameOrId);
         Assert.assertTrue("Could not find: [" + text + "]" + "in table ["
-                + tableSummaryNameOrId + "]", getDialog()
-                .getTable(tableSummaryNameOrId).hasText(text));
+                + tableSummaryNameOrId + "]", getDialog().getTable(
+                tableSummaryNameOrId).hasText(text));
     }
 
     /**
@@ -340,8 +347,8 @@
     public void assertMatchInTable(String tableSummaryNameOrId, String regexp) 
{
         assertTablePresent(tableSummaryNameOrId);
         Assert.assertTrue("Could not match: [" + regexp + "]" + "in table ["
-                + tableSummaryNameOrId + "]", getDialog()
-                .getTable(tableSummaryNameOrId).hasMatch(regexp));
+                + tableSummaryNameOrId + "]", getDialog().getTable(
+                tableSummaryNameOrId).hasMatch(regexp));
     }
 
     /**
@@ -410,8 +417,8 @@
     public void assertTextNotInTable(String tableSummaryNameOrId, String text) 
{
         assertTablePresent(tableSummaryNameOrId);
         Assert.assertTrue("Found text: [" + text + "] in table ["
-                + tableSummaryNameOrId + "]", !getDialog()
-                .getTable(tableSummaryNameOrId).hasText(text));
+                + tableSummaryNameOrId + "]", !getDialog().getTable(
+                tableSummaryNameOrId).hasText(text));
     }
 
     /**
@@ -438,8 +445,8 @@
     public void assertNoMatchInTable(String tableSummaryNameOrId, String 
regexp) {
         assertTablePresent(tableSummaryNameOrId);
         Assert.assertTrue("Found regexp: [" + regexp + "] in table ["
-                + tableSummaryNameOrId + "]", !getDialog()
-                .getTable(tableSummaryNameOrId).hasMatch(regexp));
+                + tableSummaryNameOrId + "]", !getDialog().getTable(
+                tableSummaryNameOrId).hasMatch(regexp));
     }
 
     /**
@@ -481,7 +488,8 @@
      */
     public void assertTableEquals(String tableSummaryNameOrId,
             String[][] expectedCellValues) {
-        getDialog().getTable(tableSummaryNameOrId).assertEquals(new 
Table(expectedCellValues));
+        getDialog().getTable(tableSummaryNameOrId).assertEquals(
+                new Table(expectedCellValues));
     }
 
     /**
@@ -497,7 +505,8 @@
      */
     public void assertTableRowsEqual(String tableSummaryNameOrId, int startRow,
             Table expectedTable) {
-        
getDialog().getTable(tableSummaryNameOrId).assertSubTableEquals(startRow, 
expectedTable);
+        getDialog().getTable(tableSummaryNameOrId).assertSubTableEquals(
+                startRow, expectedTable);
     }
 
     /**
@@ -513,22 +522,27 @@
      */
     public void assertTableRowsEqual(String tableSummaryNameOrId, int startRow,
             String[][] expectedTable) {
-        
getDialog().getTable(tableSummaryNameOrId).assertSubTableEquals(startRow, new 
Table(expectedTable));
+        getDialog().getTable(tableSummaryNameOrId).assertSubTableEquals(
+                startRow, new Table(expectedTable));
     }
 
     /**
-     * Assert that the number of rows for a specific table equals expected 
value.
+     * Assert that the number of rows for a specific table equals expected
+     * value.
      * 
      * @param tableSummaryNameOrId
      *            summary, name or id attribute value of table
      * @param expectedRowCount
      *            expected row count.
      */
-    public void assertTableRowCountEquals(String tableSummaryNameOrId, int 
expectedRowCount) {
+    public void assertTableRowCountEquals(String tableSummaryNameOrId,
+            int expectedRowCount) {
         assertTablePresent(tableSummaryNameOrId);
-        int actualRowCount = 
getDialog().getTable(tableSummaryNameOrId).getRowCount();
-        Assert.assertTrue("Expected row count was "+expectedRowCount+" but 
actual row count is "+actualRowCount,
-                actualRowCount==expectedRowCount);
+        int actualRowCount = getDialog().getTable(tableSummaryNameOrId)
+                .getRowCount();
+        Assert.assertTrue("Expected row count was " + expectedRowCount
+                + " but actual row count is " + actualRowCount,
+                actualRowCount == expectedRowCount);
     }
 
     /**
@@ -539,8 +553,7 @@
      * @param expectedTable
      *            represents expected regexps (colspan supported).
      */
-    public void assertTableMatch(String tableSummaryOrId,
-            Table expectedTable) {
+    public void assertTableMatch(String tableSummaryOrId, Table expectedTable) 
{
         getDialog().getTable(tableSummaryOrId).assertMatch(expectedTable);
     }
 
@@ -554,7 +567,8 @@
      */
     public void assertTableMatch(String tableSummaryOrId,
             String[][] expectedCellValues) {
-        getDialog().getTable(tableSummaryOrId).assertMatch(new 
Table(expectedCellValues));
+        getDialog().getTable(tableSummaryOrId).assertMatch(
+                new Table(expectedCellValues));
     }
 
     /**
@@ -570,7 +584,8 @@
      */
     public void assertTableRowsMatch(String tableSummaryOrId, int startRow,
             Table expectedTable) {
-        getDialog().getTable(tableSummaryOrId).assertSubTableMatch(startRow, 
expectedTable);
+        getDialog().getTable(tableSummaryOrId).assertSubTableMatch(startRow,
+                expectedTable);
     }
 
     /**
@@ -582,11 +597,13 @@
      * @param startRow
      *            index of start row for comparison
      * @param expectedTable
-     *            represents expected regexps (colspan and rowspan not 
supported).
+     *            represents expected regexps (colspan and rowspan not
+     *            supported).
      */
     public void assertTableRowsMatch(String tableSummaryOrId, int startRow,
             String[][] expectedTable) {
-        getDialog().getTable(tableSummaryOrId).assertSubTableMatch(startRow, 
new Table(expectedTable));
+        getDialog().getTable(tableSummaryOrId).assertSubTableMatch(startRow,
+                new Table(expectedTable));
     }
 
     /**
@@ -1057,8 +1074,8 @@
      */
     public void assertSubmitButtonPresent() {
         assertFormPresent();
-        Assert.assertTrue("no submit button found.",
-                getDialog().hasSubmitButton());
+        Assert.assertTrue("no submit button found.", getDialog()
+                .hasSubmitButton());
     }
 
     /**
@@ -1079,8 +1096,8 @@
      */
     public void assertSubmitButtonNotPresent() {
         assertFormPresent();
-        Assert.assertFalse("Submit Button found.",
-                getDialog().hasSubmitButton());
+        Assert.assertFalse("Submit Button found.", getDialog()
+                .hasSubmitButton());
     }
 
     /**
@@ -1113,8 +1130,8 @@
      */
     public void assertResetButtonPresent() {
         assertFormPresent();
-        Assert.assertTrue("no reset button found.",
-                getDialog().hasResetButton());
+        Assert.assertTrue("no reset button found.", getDialog()
+                .hasResetButton());
     }
 
     /**
@@ -1135,8 +1152,7 @@
      */
     public void assertResetButtonNotPresent() {
         assertFormPresent();
-        Assert.assertFalse("Reset Button found.",
-                getDialog().hasResetButton());
+        Assert.assertFalse("Reset Button found.", 
getDialog().hasResetButton());
     }
 
     /**
@@ -1373,8 +1389,8 @@
      *            element xpath to test for.
      */
     public void assertElementPresentByXPath(String xpath) {
-        Assert.assertTrue("Unable to locate element with xpath \"" + xpath + 
"\"",
-                getDialog().hasElementByXPath(xpath));
+        Assert.assertTrue("Unable to locate element with xpath \"" + xpath
+                + "\"", getDialog().hasElementByXPath(xpath));
     }
 
     /**
@@ -1457,6 +1473,17 @@
     }
 
     /**
+     * Assert that a window with the given ID is open.
+     * 
+     * @param windowID
+     *            Javascript window ID.
+     */
+    public void assertWindowPresent(int windowID) {
+        Assert.assertTrue("There is no window with index [" + windowID + "].",
+                getDialog().getWindowCount() > windowID);
+    }
+
+    /**
      * Assert that at least one window with the given title is open.
      * 
      * @param title
@@ -1468,6 +1495,18 @@
     }
 
     /**
+     * Assert that the number of opened windows equals given value.
+     * 
+     * @param windowCount
+     *            Window count
+     */
+    public void assertWindowCountEquals(int windowCount) {
+        Assert.assertTrue("Window count is " + getDialog().getWindowCount()
+                + " but " + windowCount + " was expected.", getDialog()
+                .getWindowCount()==windowCount);
+    }
+
+    /**
      * Assert that a frame with the given name is present.
      * 
      * @param frameName
@@ -1840,6 +1879,7 @@
     /**
      * Search for labelText in the document, then search forward until finding 
a
      * link called linkText. Click it.
+     * 
      * @deprecated
      */
     public void clickLinkWithTextAfterText(String linkText, String labelText) {
@@ -1903,7 +1943,7 @@
         assertRadioOptionPresent(radioGroup, radioOption);
         getDialog().clickRadioOption(radioGroup, radioOption);
     }
-    
+
     /**
      * Click element with given xpath.
      * 
@@ -1918,7 +1958,7 @@
     // Window and Frame Navigation Methods
 
     /**
-     * Make a given window active (current response will be window's contents).
+     * Make a given window active.
      * 
      * @param windowName
      */
@@ -1928,6 +1968,17 @@
     }
 
     /**
+     * Make a given window active.
+     * 
+     * @param windowID
+     *            Javascript ID of the window
+     */
+    public void gotoWindow(int windowID) {
+        assertWindowPresent(windowID);
+        getDialog().gotoWindow(windowID);
+    }
+
+    /**
      * Make the root window active.
      */
     public void gotoRootWindow() {
@@ -2023,16 +2074,16 @@
      * @param stream
      */
     public void dumpTable(String tableNameOrId, PrintStream stream) {
-//        String[][] table = getDialog().getTable(tableNameOrId).getStrings();
-//        //TODO Print correctly cells with colspan
-//        stream.print("\n" + tableNameOrId + ":");
-//        for (int i = 0; i < table.length; i++) {
-//            String[] cell = table[i];
-//            stream.print("\n\t");
-//            for (int j = 0; j < cell.length; j++) {
-//                stream.print("[" + cell[j] + "]");
-//            }
-//        }
+        // String[][] table = getDialog().getTable(tableNameOrId).getStrings();
+        // //TODO Print correctly cells with colspan
+        // stream.print("\n" + tableNameOrId + ":");
+        // for (int i = 0; i < table.length; i++) {
+        // String[] cell = table[i];
+        // stream.print("\n\t");
+        // for (int j = 0; j < cell.length; j++) {
+        // stream.print("[" + cell[j] + "]");
+        // }
+        // }
 
     }
 
@@ -2095,18 +2146,18 @@
      * Exemple: <br/>
      * 
      * <pre>
-     *             &lt;FORM action=&quot;http://my_host/doit&quot; 
method=&quot;post&quot;&gt;
-     *               &lt;P&gt;
-     *                 &lt;SELECT multiple size=&quot;4&quot; 
name=&quot;component-select&quot;&gt;
-     *                   &lt;OPTION selected 
value=&quot;Component_1_a&quot;&gt;Component_1&lt;/OPTION&gt;
-     *                   &lt;OPTION selected 
value=&quot;Component_1_b&quot;&gt;Component_2&lt;/OPTION&gt;
-     *                   &lt;OPTION&gt;Component_3&lt;/OPTION&gt;
-     *                   &lt;OPTION&gt;Component_4&lt;/OPTION&gt;
-     *                   &lt;OPTION&gt;Component_5&lt;/OPTION&gt;
-     *                 &lt;/SELECT&gt;
-     *                 &lt;INPUT type=&quot;submit&quot; 
value=&quot;Send&quot;&gt;&lt;INPUT type=&quot;reset&quot;&gt;
-     *               &lt;/P&gt;
-     *             &lt;/FORM&gt;
+     *               &lt;FORM action=&quot;http://my_host/doit&quot; 
method=&quot;post&quot;&gt;
+     *                 &lt;P&gt;
+     *                   &lt;SELECT multiple size=&quot;4&quot; 
name=&quot;component-select&quot;&gt;
+     *                     &lt;OPTION selected 
value=&quot;Component_1_a&quot;&gt;Component_1&lt;/OPTION&gt;
+     *                     &lt;OPTION selected 
value=&quot;Component_1_b&quot;&gt;Component_2&lt;/OPTION&gt;
+     *                     &lt;OPTION&gt;Component_3&lt;/OPTION&gt;
+     *                     &lt;OPTION&gt;Component_4&lt;/OPTION&gt;
+     *                     &lt;OPTION&gt;Component_5&lt;/OPTION&gt;
+     *                   &lt;/SELECT&gt;
+     *                   &lt;INPUT type=&quot;submit&quot; 
value=&quot;Send&quot;&gt;&lt;INPUT type=&quot;reset&quot;&gt;
+     *                 &lt;/P&gt;
+     *               &lt;/FORM&gt;
      * </pre>
      * 
      * Should return [Component_1, Component_2, Component_3, Component_4,
@@ -2150,7 +2201,7 @@
                     returned[i]);
         }
     }
-    
+
     /**
      * Return a sparse array (rows or columns without displayable text are
      * removed) for a given table in the response.
@@ -2158,22 +2209,16 @@
      * @param tableSummaryNameOrId
      *            summary or id of the table.
      */
-//    private String[][] getSparseTable(String tableSummaryNameOrId) {
-//        
-//    }
-    
+    // private String[][] getSparseTable(String tableSummaryNameOrId) {
+    //        
+    // }
     /**
      * Return a array for a given table.
      * 
      * @param tableSummaryNameOrId
      *            summary or id of the table.
      */
-//    private String[][] getTable(String tableSummaryNameOrId) {
-//        
-//    }
-
-
-
-
-
+    // private String[][] getTable(String tableSummaryNameOrId) {
+    //        
+    // }
 }
\ No newline at end of file

Modified: 
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitDialog.java
===================================================================
--- 
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitDialog.java
  2006-06-21 09:21:32 UTC (rev 487)
+++ 
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitDialog.java
  2006-06-21 09:27:06 UTC (rev 488)
@@ -137,7 +137,7 @@
         }
     }
 
-    public void closeBrowser() throws TestingEngineResponseException {
+    public void closeBrowser() {
         wc = null;
     }
 
@@ -239,6 +239,14 @@
         setMainWindow(getWindow(windowName));
     }
 
+    public void gotoWindow(int windowID) {
+        setMainWindow((WebWindow)wc.getWebWindows().get(windowID));
+    }
+    
+    public int getWindowCount() {
+        return wc.getWebWindows().size();
+    }
+
     /**
      * Goto first window with the given title.
      * 
@@ -252,8 +260,15 @@
     }
 
     public void closeWindow() {
-        // TODO Implement closeWindow in HtmlUnitDialog
-        throw new UnsupportedOperationException("closeWindow");
+        if (getWindowCount()==1) {
+            closeBrowser();
+        }
+        else {
+            wc.deregisterWebWindow(win);
+            win=wc.getCurrentWindow();
+            form=null;
+        }
+        
     }
 
     public boolean hasFrame(String frameName) {

Modified: 
trunk/jwebunit-httpunit-plugin/src/main/java/net/sourceforge/jwebunit/httpunit/HttpUnitDialog.java
===================================================================
--- 
trunk/jwebunit-httpunit-plugin/src/main/java/net/sourceforge/jwebunit/httpunit/HttpUnitDialog.java
  2006-06-21 09:21:32 UTC (rev 487)
+++ 
trunk/jwebunit-httpunit-plugin/src/main/java/net/sourceforge/jwebunit/httpunit/HttpUnitDialog.java
  2006-06-21 09:27:06 UTC (rev 488)
@@ -186,7 +186,7 @@
     }
 
     /**
-     * Return the page title of the current response page, encoded as specified
+     * Return the page title of the current page, encoded as specified
      * by the current [EMAIL PROTECTED] net.sourceforge.jwebunit.TestContext}.
      */
     public String getPageTitle() {
@@ -1483,6 +1483,14 @@
         setMainWindow(getWindow(windowName));
     }
 
+    public void gotoWindow(int windowID) {
+        setMainWindow(wc.getOpenWindows()[windowID]);
+    }
+    
+    public int getWindowCount() {
+        return wc.getOpenWindows().length;
+    }
+
     /**
      * Goto first window with the given title.
      * 
@@ -1684,15 +1692,21 @@
         }
     }
 
-    public void closeBrowser() throws TestingEngineResponseException {
+    public void closeBrowser() {
         wc = null;
         resp = null;
         form = null;
     }
 
     public void closeWindow() {
-        // TODO Auto-generated method stub
-
+        wc.getMainWindow().close();
+        if (wc.getOpenWindows().length>0) {
+            wc.setMainWindow(wc.getOpenWindows()[0]);
+            resp=wc.getMainWindow().getCurrentPage();
+            form=null;
+        }            
+        else
+            closeBrowser();        
     }
 
     /*

Modified: 
trunk/jwebunit-jacobie-plugin/src/main/java/net/sourceforge/jwebunit/jacobie/JacobieDialog.java
===================================================================
--- 
trunk/jwebunit-jacobie-plugin/src/main/java/net/sourceforge/jwebunit/jacobie/JacobieDialog.java
     2006-06-21 09:21:32 UTC (rev 487)
+++ 
trunk/jwebunit-jacobie-plugin/src/main/java/net/sourceforge/jwebunit/jacobie/JacobieDialog.java
     2006-06-21 09:27:06 UTC (rev 488)
@@ -1430,4 +1430,14 @@
         return false;
     }
 
+    public int getWindowCount() {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    public void gotoWindow(int windowID) {
+        // TODO Auto-generated method stub
+        
+    }
+
 }
\ No newline at end of file

Modified: 
trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumDialog.java
===================================================================
--- 
trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumDialog.java
  2006-06-21 09:21:32 UTC (rev 487)
+++ 
trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumDialog.java
  2006-06-21 09:27:06 UTC (rev 488)
@@ -447,7 +447,15 @@
     protected String formSelector() {
         if (formIdent == null)
             return "";
-
         return "//form[" + formIdent + "]";
     }
+
+    public int getWindowCount() {
+        //TODO implement getWindowCount in SeleniumDialog
+        throw new UnsupportedOperationException("getWindowCount");
+    }
+
+    public void gotoWindow(int windowID) {
+        selenium.selectWindow(""+windowID);
+    }
 }
\ No newline at end of file


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Jwebunit-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development

Reply via email to