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

Log Message:
-----------
Clean unused methods.
Add some files to svn:ignore

Modified Paths:
--------------
    
branches/1.x/jwebunit-core/src/main/java/net/sourceforge/jwebunit/IJWebUnitDialog.java
    
branches/1.x/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitDialog.java

Property Changed:
----------------
    branches/1.x/jwebunit-commons-tests/
    branches/1.x/jwebunit-core/
    branches/1.x/jwebunit-htmlunit-plugin/

Property changes on: branches/1.x/jwebunit-commons-tests
___________________________________________________________________
Name: svn:ignore
   + .classpath
.project



Property changes on: branches/1.x/jwebunit-core
___________________________________________________________________
Name: svn:ignore
   + .project
.classpath


Modified: 
branches/1.x/jwebunit-core/src/main/java/net/sourceforge/jwebunit/IJWebUnitDialog.java
===================================================================
--- 
branches/1.x/jwebunit-core/src/main/java/net/sourceforge/jwebunit/IJWebUnitDialog.java
      2006-06-26 14:59:31 UTC (rev 508)
+++ 
branches/1.x/jwebunit-core/src/main/java/net/sourceforge/jwebunit/IJWebUnitDialog.java
      2006-06-27 09:02:50 UTC (rev 509)
@@ -38,16 +38,6 @@
     void gotoPage(String url) throws TestingEngineResponseException;
 
     /**
-     * Simulate user pressing "go back" button of the browser.
-     */
-    void goBack();
-
-    /**
-     * Simulate user pressing "refresh" button of the browser.
-     */
-    void refresh();
-
-    /**
      * Enable or disable Javascript support
      */
     void setScriptingEnabled(boolean value);


Property changes on: branches/1.x/jwebunit-htmlunit-plugin
___________________________________________________________________
Name: svn:ignore
   + .project
.classpath


Modified: 
branches/1.x/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitDialog.java
===================================================================
--- 
branches/1.x/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitDialog.java
   2006-06-26 14:59:31 UTC (rev 508)
+++ 
branches/1.x/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitDialog.java
   2006-06-27 09:02:50 UTC (rev 509)
@@ -151,16 +151,6 @@
         }
     }
 
-    public void goBack() {
-        // TODO Implement goBack in HtmlUnitDialog
-        throw new UnsupportedOperationException("goBack");
-    }
-
-    public void refresh() {
-        // TODO Implement refresh in HtmlUnitDialog
-        throw new UnsupportedOperationException("refresh");
-    }
-
     /**
      * @see 
net.sourceforge.jwebunit.IJWebUnitDialog#setScriptingEnabled(boolean)
      */
@@ -350,23 +340,6 @@
         getForm().getInputByName(fieldName).setValueAttribute(paramValue);
     }
 
-    // /**
-    // * Return a string array of select box option labels.
-    // *
-    // * @param selectName
-    // * name of the select box.
-    // */
-    // public String[] getOptionsFor(String selectName) {
-    // HtmlSelect sel = getForm().getSelectByName(selectName);
-    // ArrayList result = new ArrayList();
-    // List opts = sel.getOptions();
-    // for (int i = 0; i < opts.size(); i++) {
-    // HtmlOption opt = (HtmlOption) opts.get(i);
-    // result.add(opt.asText());
-    // }
-    // return (String[]) result.toArray(new String[0]);
-    // }
-
     /**
      * Return a string array of select box option values.
      * 
@@ -1050,19 +1023,6 @@
      * 
      * @param linkText
      *            text to check for in links on the response.
-     */
-    public boolean hasLinkWithText(String linkText) {
-        return getLinkWithText(linkText) != null;
-    }
-
-    /**
-     * Return true if a link is present in the current response containing the
-     * specified text (note that HttpUnit uses contains rather than an exact
-     * match - if this is a problem consider using ids on the links to uniquely
-     * identify them).
-     * 
-     * @param linkText
-     *            text to check for in links on the response.
      * @param index
      *            The 0-based index, when more than one link with the same text
      *            is expected.
@@ -1071,6 +1031,10 @@
         return getLinkWithText(linkText, index) != null;
     }
 
+    public boolean hasLinkWithExactText(String linkText, int index) {
+        return getLinkWithExactText(linkText, index) != null;
+    }
+
     public boolean hasLinkWithImage(String imageFileName, int index) {
         return getLinkWithImage(imageFileName, index) != null;
     }
@@ -1091,46 +1055,20 @@
         return true;
     }
 
-    /*
-     * @see 
net.sourceforge.jwebunit.IJWebUnitDialog#isLinkPresentWithText(java.lang.String,
-     *      int)
-     */
-    public boolean hasLinkWithExactText(String linkText, int index) {
-        throw new UnsupportedOperationException("isLinkPresentWithText");
+    public void clickLinkWithText(String linkText, int index) {
+        HtmlAnchor link = getLinkWithText(linkText, index);
+        if (link == null)
+            throw new RuntimeException("No Link found for \"" + linkText
+                    + "\" with index " + index);
+        try {
+            link.click();
+        } catch (IOException e) {
+            throw new RuntimeException("Click failed");
+        }
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see 
net.sourceforge.jwebunit.IJWebUnitDialog#clickLinkWithExactText(java.lang.String)
-     */
-    public void clickLinkWithExactText(String linkText) {
-        throw new UnsupportedOperationException("clickLinkWithExactText");
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see 
net.sourceforge.jwebunit.IJWebUnitDialog#clickLinkWithExactText(java.lang.String,
-     *      int)
-     */
     public void clickLinkWithExactText(String linkText, int index) {
-        throw new UnsupportedOperationException("clickLinkWithExactText");
-    }
-
-    /**
-     * Navigate by submitting a request based on a link containing the 
specified
-     * text. A RuntimeException is thrown if no such link can be found.
-     * 
-     * @param linkText
-     *            text which link to be navigated should contain.
-     */
-    public void clickLinkWithText(String linkText) {
-        clickLinkWithText(linkText, 0);
-    }
-
-    public void clickLinkWithText(String linkText, int index) {
-        HtmlAnchor link = getLinkWithText(linkText, index);
+        HtmlAnchor link = getLinkWithExactText(linkText, index);
         if (link == null)
             throw new RuntimeException("No Link found for \"" + linkText
                     + "\" with index " + index);
@@ -1252,10 +1190,6 @@
         clickElementByXPath("//[EMAIL PROTECTED]"" + anID + "\"]");
     }
 
-    private HtmlAnchor getLinkWithText(String linkText) {
-        return getLinkWithText(linkText, 0);
-    }
-
     private HtmlAnchor getLinkWithImage(String filename, int index) {
         return (HtmlAnchor) getElementByXPath("(//a[img[contains(@src,\""
                 + filename + "\")]])[" + index + 1 + "]");
@@ -1272,6 +1206,17 @@
         return null;
     }
 
+    private HtmlAnchor getLinkWithExactText(String linkText, int index) {
+        List lnks = ((HtmlPage) win.getEnclosedPage()).getAnchors();
+        int count = 0;
+        for (int i = 0; i < lnks.size(); i++) {
+            HtmlAnchor lnk = (HtmlAnchor) lnks.get(i);
+            if ((lnk.asText().equals(linkText)) && (count++ == index))
+                return lnk;
+        }
+        return null;
+    }
+
     /**
      * Navigate by submitting a request based on a link with a given image file
      * name. A RuntimeException is thrown if no such link can be found.
@@ -1440,19 +1385,6 @@
         }
     }
 
-    /**
-     * Select an option of a select box by value.
-     * 
-     * @param selectName
-     *            name of the select box.
-     * @param option
-     *            value of the option to select.
-     */
-    public void selectOptionByValue(String selectName, String option) {
-        HtmlSelect sel = getForm().getSelectByName(selectName);
-        sel.setSelectedAttribute(option, true);
-    }
-
     public boolean isTextInElement(String elementID, String text) {
         return isTextInElement(getElement(elementID), text);
     }


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


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Jwebunit-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development

Reply via email to