Revision: 813
          http://jwebunit.svn.sourceforge.net/jwebunit/?rev=813&view=rev
Author:   henryju
Date:     2009-09-03 12:56:30 +0000 (Thu, 03 Sep 2009)

Log Message:
-----------
Updated to HtmlUnit 2.6. Removed deprecated methods.

Modified Paths:
--------------
    
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitElementImpl.java
    
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
    trunk/pom.xml
    trunk/src/changes/changes.xml

Modified: 
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitElementImpl.java
===================================================================
--- 
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitElementImpl.java
     2009-08-14 22:57:11 UTC (rev 812)
+++ 
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitElementImpl.java
     2009-09-03 12:56:30 UTC (rev 813)
@@ -121,7 +121,7 @@
         * @see 
net.sourceforge.jwebunit.api.IElement#setAttribute(java.lang.String)
         */
        public void setAttribute(String string) {
-               element.setAttributeValue(string, "1");
+               element.setAttributeNS(null, string, "1");
        }
 
 
@@ -133,7 +133,7 @@
                        // for HtmlInputs, we want to run any onChange code if 
the value changes
                        ((HtmlInput) element).setValueAttribute(value);
                } else {
-                       element.setAttributeValue(string, value);
+                       element.setAttributeNS(null, string, value);
                }
        }
 

Modified: 
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
===================================================================
--- 
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
       2009-08-14 22:57:11 UTC (rev 812)
+++ 
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
       2009-09-03 12:56:30 UTC (rev 813)
@@ -63,7 +63,6 @@
 import com.gargoylesoftware.htmlunit.WebWindowEvent;
 import com.gargoylesoftware.htmlunit.WebWindowListener;
 import com.gargoylesoftware.htmlunit.WebWindowNotFoundException;
-import com.gargoylesoftware.htmlunit.html.ClickableElement;
 import com.gargoylesoftware.htmlunit.html.DomComment;
 import com.gargoylesoftware.htmlunit.html.DomNode;
 import com.gargoylesoftware.htmlunit.html.FrameWindow;
@@ -150,7 +149,7 @@
     /**
      * The default browser version.
      */
-    BrowserVersion defaultBrowserVersion = BrowserVersion.FIREFOX_2;
+    BrowserVersion defaultBrowserVersion = BrowserVersion.FIREFOX_3;
     
     /**
      * Should we ignore failing status codes?
@@ -670,7 +669,7 @@
     
     
     public URL getPageURL() {
-        return win.getEnclosedPage().getWebResponse().getUrl();
+        return 
win.getEnclosedPage().getWebResponse().getRequestSettings().getUrl();
     }
     
     public String getPageSource() {
@@ -705,7 +704,7 @@
                 .getWebResponse();
         result.append(wr.getStatusCode()).append(" ").append(
                 wr.getStatusMessage()).append("\n");
-        result.append("Location: ").append(wr.getUrl()).append("\n");
+        result.append("Location: 
").append(wr.getRequestSettings().getUrl()).append("\n");
         for (NameValuePair h : wr.getResponseHeaders()) {
             result.append(h.getName()).append(": ").append(h.getValue())
                     .append("\n");
@@ -757,8 +756,10 @@
         */
        BrowserVersion bv;
        if (testContext.getUserAgent() != null) {
-            bv = new BrowserVersion(BrowserVersion.INTERNET_EXPLORER,
-                    "4.0", testContext.getUserAgent(), "1.2", 6);
+            bv = new BrowserVersion(
+                       BrowserVersion.NETSCAPE, "5.0 (Windows; en-US)",
+                       testContext.getUserAgent(),
+                    3);
        } else {
                bv = defaultBrowserVersion;             // use default (which 
includes a full UserAgent string)
        }
@@ -1030,7 +1031,7 @@
     private HtmlForm getForm(String nameOrID, int index) {
         List<HtmlForm> forms = new ArrayList<HtmlForm>();
         for (HtmlForm form : getCurrentPage().getForms()) {
-            if (nameOrID.equals(form.getIdAttribute())
+            if (nameOrID.equals(form.getId())
                     || nameOrID.equals(form.getNameAttribute())) {
                 forms.add(form);
             }
@@ -1043,63 +1044,6 @@
         }
     }
 
-    private HtmlForm getFormWithInput(String inputName) {
-        // Search in Working form if available
-        if (form != null) {
-            if (!form.getHtmlElementsByAttribute("input",
-                    "name", inputName).isEmpty()) {
-                return form;
-            }
-            if (!form.getTextAreasByName(inputName).isEmpty()) {
-                return form;
-            }
-        } else {
-            if (hasForm()) {
-                for (HtmlForm form : getForms()) {
-                    List<HtmlElement> inputElements = new 
LinkedList<HtmlElement>();
-                    
inputElements.addAll(form.getHtmlElementsByAttribute("input",
-                            "name", inputName));
-                    if (inputElements.isEmpty()) {
-                        
inputElements.addAll(form.getTextAreasByName(inputName));
-                    }
-                    if (!inputElements.isEmpty()) {
-                        setWorkingForm(form);
-                        return form;
-                    }
-                }
-            }
-        }
-        return null;
-    }
-
-    private HtmlForm getFormWithSelect(String selectName) {
-        // Search in Working form if available
-        if (form != null) {
-            try {
-                if (form.getSelectByName(selectName) != null) {
-                    return form;
-                }
-            } catch (ElementNotFoundException e) {
-                // Nothing
-            }
-        } else {
-            if (hasForm()) {
-                for (int i = 0; i < getForms().size(); i++) {
-                    HtmlForm form = (HtmlForm) getForms().get(i);
-                    try {
-                        if (form.getSelectByName(selectName) != null) {
-                            setWorkingForm(form);
-                            return form;
-                        }
-                    } catch (ElementNotFoundException e) {
-                        // Nothing
-                    }
-                }
-            }
-        }
-        return null;
-    }
-
     private List<HtmlForm> getForms() {
         HtmlPage page = (HtmlPage) win.getEnclosedPage();
         return page.getForms();
@@ -1163,7 +1107,7 @@
      * @param buttonName name of button.
      * @return the button
      */
-    public ClickableElement getSubmitButton(String buttonName) {
+    public HtmlElement getSubmitButton(String buttonName) {
         List<HtmlElement> btns = new LinkedList<HtmlElement>();
         if (form != null) {
             btns.addAll(getForm().getInputsByName(buttonName));
@@ -1237,7 +1181,7 @@
      * @param buttonValue button value.
      * @return HtmlSubmitInput, HtmlImageInput or HtmlButton
      */
-    public ClickableElement getSubmitButton(String buttonName,
+    public HtmlElement getSubmitButton(String buttonName,
             String buttonValue) {
         List<HtmlElement> btns = new LinkedList<HtmlElement>();
         if (form != null) {
@@ -1325,14 +1269,14 @@
      * 
      * @param buttonId
      */
-    private ClickableElement getButton(String buttonId) {
+    private HtmlElement getButton(String buttonId) {
         HtmlElement btn = null;
         try {
             btn = getCurrentPage().getHtmlElementById(buttonId);
             if (btn instanceof HtmlButton || btn instanceof HtmlButtonInput
                     || btn instanceof HtmlSubmitInput
                     || btn instanceof HtmlResetInput)
-                return (ClickableElement) btn;
+                return btn;
         } catch (ElementNotFoundException e) {
             return null;
         }
@@ -1363,7 +1307,7 @@
      * @return the ClickableElement with the specified text or null if 
      * no such button is found. 
      */
-    public ClickableElement getButtonWithText(String buttonValueText) {
+    public HtmlElement getButtonWithText(String buttonValueText) {
         List<? extends HtmlElement> l = ((HtmlPage) 
win.getEnclosedPage()).getDocumentElement()
                 .getHtmlElementsByTagNames(
                         Arrays.asList(new String[] { "button", "input" }));
@@ -1371,14 +1315,14 @@
             if ( e instanceof HtmlButton )
             {
                if (((HtmlButton) e).asText().equals(buttonValueText))
-                       return (ClickableElement) e;
+                       return e;
             }
             else if ( e instanceof HtmlButtonInput ||
                          e instanceof HtmlSubmitInput ||
                          e instanceof HtmlResetInput )
             {
-               if ( buttonValueText.equals(e.getAttributeValue("value")) )
-                       return (ClickableElement)e;
+               if ( buttonValueText.equals(e.getAttribute("value")) )
+                       return e;
             }
         }
         return null;
@@ -1526,11 +1470,11 @@
      * @param buttonName name of the button to use for submission.
      */
     public void submit(String buttonName) {
-        List<ClickableElement> l = new LinkedList<ClickableElement>();
+        List<HtmlElement> l = new LinkedList<HtmlElement>();
         l.addAll(getForm().getInputsByName(buttonName));
         l.addAll(getForm().getButtonsByName(buttonName));
         try {
-            for (ClickableElement o : l) {
+            for (HtmlElement o : l) {
                 if (o instanceof HtmlSubmitInput) {
                     HtmlSubmitInput inpt = (HtmlSubmitInput) o;
                     inpt.click();
@@ -1571,7 +1515,7 @@
      * @param buttonValue value/label of the button to use for submission
      */
     public void submit(String buttonName, String buttonValue) {
-        List<ClickableElement> l = new LinkedList<ClickableElement>();
+        List<HtmlElement> l = new LinkedList<HtmlElement>();
         l.addAll(getForm().getInputsByName(buttonName));
         l.addAll(getForm().getButtonsByName(buttonName));
         try {
@@ -1856,11 +1800,7 @@
             throw new RuntimeException("No element found with xpath \"" + xpath
                     + "\"");
         try {
-            ClickableElement c = (ClickableElement) e;
-            c.click();
-        } catch (ClassCastException exp) {
-            throw new RuntimeException("Element with xpath \"" + xpath
-                    + "\" is not clickable", exp);
+            e.click();
         } catch (IOException exp) {
             throw new RuntimeException("Click failed", exp);
         }
@@ -1870,7 +1810,7 @@
         HtmlElement e = getHtmlElementByXPath(xpath);
         if (e == null)
             return null;
-        return e.getAttributeValue(attribut);
+        return e.getAttribute(attribut);
     }
 
 
@@ -1889,7 +1829,7 @@
      * @param buttonId
      */
     public void clickButton(String buttonId) {
-        ClickableElement btn = getButton(buttonId);
+        HtmlElement btn = getButton(buttonId);
         try {
             btn.click();
         } catch (Exception e) {
@@ -1904,7 +1844,7 @@
      * content by converting it to text.  or an HTML &lt;button&gt; tag.
      */
     public void clickButtonWithText(String buttonValueText) {
-       ClickableElement b = getButtonWithText(buttonValueText);
+       HtmlElement b = getButtonWithText(buttonValueText);
        if (b != null) {
                try {
                        b.click();

Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml       2009-08-14 22:57:11 UTC (rev 812)
+++ trunk/pom.xml       2009-09-03 12:56:30 UTC (rev 813)
@@ -295,7 +295,7 @@
                        <dependency>
                                <groupId>net.sourceforge.htmlunit</groupId>
                                <artifactId>htmlunit</artifactId>
-                               <version>2.5</version>
+                               <version>2.6</version>
                        </dependency>
                        <dependency>
                                
<groupId>org.seleniumhq.selenium.client-drivers</groupId>

Modified: trunk/src/changes/changes.xml
===================================================================
--- trunk/src/changes/changes.xml       2009-08-14 22:57:11 UTC (rev 812)
+++ trunk/src/changes/changes.xml       2009-09-03 12:56:30 UTC (rev 813)
@@ -7,8 +7,14 @@
         </author>
     </properties>
     <body>
-        <release version="2.3" date="UNKNOW">
+        <release version="2.3" date="UNKNOW" description="Updated to JUnit 
4.7">
             <action type="update" dev="henryju">
+                Updated to HtmlUnit 2.6.
+            </action>
+            <action type="update" dev="henryju">
+                Updated to JUnit 4.7.
+            </action>
+            <action type="update" dev="henryju">
                 Updated to Selenium RC 1.0.
             </action>
         </release>
@@ -65,7 +71,7 @@
                 Cleaned up the quickstart documentation.
             </action>
         </release>
-        <release version="2.0" date="October 27, 2008">
+        <release version="2.0" date="October 27, 2008" description="First 
release that requires Java 1.4+">
             <action type="update" dev="henryju">
                 Updated to HtmlUnit 2.3.
             </action>


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

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
JWebUnit-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development

Reply via email to