Revision: 534
Author:   henryju
Date:     2006-07-25 07:05:49 -0700 (Tue, 25 Jul 2006)
ViewCVS:  http://svn.sourceforge.net/jwebunit/?rev=534&view=rev

Log Message:
-----------
Apply patch for TextArea support (thanks to Fred Burlet)
Add Fred Burlet to contributors
Update changes.xml

Modified Paths:
--------------
    
branches/1.x/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormAssertionsTest.java
    
branches/1.x/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormSubmissionTest.java
    
branches/1.x/jwebunit-commons-tests/src/main/resources/testcases/FormSubmissionTest/QueryFormSimple.html
    
branches/1.x/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitDialog.java
    branches/1.x/pom.xml
    branches/1.x/src/changes/changes.xml

Added Paths:
-----------
    
branches/1.x/jwebunit-commons-tests/src/main/resources/testcases/FormSubmissionTest/TextAreaForm.html
Modified: 
branches/1.x/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormAssertionsTest.java
===================================================================
--- 
branches/1.x/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormAssertionsTest.java
    2006-07-11 15:26:37 UTC (rev 533)
+++ 
branches/1.x/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormAssertionsTest.java
    2006-07-25 14:05:49 UTC (rev 534)
@@ -32,6 +32,7 @@
         assertPassFail("assertFormElementPresent", "testInputElement", 
"noSuchElement");
         assertPass("assertFormElementPresent", "checkboxselected");
         assertPass("assertFormElementEmpty", "testInputElement2");
+        assertPass("assertFormElementPresent", "text");
     }
 
     public void testAssertFormParameterNotPresent() throws Throwable {

Modified: 
branches/1.x/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormSubmissionTest.java
===================================================================
--- 
branches/1.x/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormSubmissionTest.java
    2006-07-11 15:26:37 UTC (rev 533)
+++ 
branches/1.x/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormSubmissionTest.java
    2006-07-25 14:05:49 UTC (rev 534)
@@ -47,6 +47,18 @@
         assertTextPresent("Params are: color=red");
     }
 
+    public void testSetTextArea() {
+        beginAt("/TextAreaForm.html");
+        setTextField("text", "sometext");
+        submit("button");
+        assertTextPresent("Submitted parameters");
+        assertTextPresent("Params are: text=sometext");
+        clickLink("return");
+        setTextField("text", "anothertext");
+        submit();
+        assertTextPresent("Params are: text=anothertext");
+    }
+
     public void testSetFileField() {
         beginAt("/InputFileForm.html");
         File temp = null;
@@ -227,4 +239,4 @@
         assertTextPresent("Page 3");
     }
 
-}
\ No newline at end of file
+}

Modified: 
branches/1.x/jwebunit-commons-tests/src/main/resources/testcases/FormSubmissionTest/QueryFormSimple.html
===================================================================
--- 
branches/1.x/jwebunit-commons-tests/src/main/resources/testcases/FormSubmissionTest/QueryFormSimple.html
    2006-07-11 15:26:37 UTC (rev 533)
+++ 
branches/1.x/jwebunit-commons-tests/src/main/resources/testcases/FormSubmissionTest/QueryFormSimple.html
    2006-07-25 14:05:49 UTC (rev 534)
@@ -3,7 +3,7 @@
        <body>
                <form method=GET action="../params.jsp">
                First : <input type="text" name="param1"/>
-               Second : <textarea name="param2"/>
+               Second : <textarea name="param2"></textarea>
                <input type="hidden" name="myReferer" 
value="FormSubmissionTest/QueryFormSimple.html"/>
                </form>
        </body>

Added: 
branches/1.x/jwebunit-commons-tests/src/main/resources/testcases/FormSubmissionTest/TextAreaForm.html
===================================================================
--- 
branches/1.x/jwebunit-commons-tests/src/main/resources/testcases/FormSubmissionTest/TextAreaForm.html
                               (rev 0)
+++ 
branches/1.x/jwebunit-commons-tests/src/main/resources/testcases/FormSubmissionTest/TextAreaForm.html
       2006-07-25 14:05:49 UTC (rev 534)
@@ -0,0 +1,10 @@
+<html>
+<head></head>
+<body>
+       <form method="GET" action="../params.jsp">
+               <textarea name="text"></textarea>
+               <input type="submit" name="button">
+               <input type="hidden" name="myReferer" 
value="FormSubmissionTest/TextAreaForm.html">
+       </form>
+</body>
+</html>
\ No newline at end of file

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-07-11 15:26:37 UTC (rev 533)
+++ 
branches/1.x/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitDialog.java
   2006-07-25 14:05:49 UTC (rev 534)
@@ -56,6 +56,7 @@
 import com.gargoylesoftware.htmlunit.html.HtmlTableRow;
 import com.gargoylesoftware.htmlunit.html.ClickableElement;
 import com.gargoylesoftware.htmlunit.html.HtmlRadioButtonInput;
+import com.gargoylesoftware.htmlunit.html.HtmlTextArea;
 import com.gargoylesoftware.htmlunit.ElementNotFoundException;
 import com.gargoylesoftware.htmlunit.html.HtmlTableRow.CellIterator;
 import com.gargoylesoftware.htmlunit.html.xpath.HtmlUnitXPath;
@@ -329,16 +330,26 @@
     }
 
     /**
-     * Set a form text or password element to the provided value.
+     * Set a form text, password input element or textarea to the provided 
value.
      * 
      * @param fieldName
-     *            name of the input element
+     *            name of the input element or textarea
      * @param paramValue
      *            parameter value to submit for the element.
      */
     public void setTextField(String fieldName, String paramValue) {
         checkFormStateWithInput(fieldName);
-        getForm().getInputByName(fieldName).setValueAttribute(paramValue);
+        List inputElements = getForm().getHtmlElementsByAttribute("input", 
"name", fieldName);
+        if (!inputElements.isEmpty()) {
+            HtmlInput input = (HtmlInput) inputElements.get(0);
+            input.setValueAttribute(paramValue);
+        } else {
+            inputElements = getForm().getTextAreasByName(fieldName);
+            if (!inputElements.isEmpty()) {
+                HtmlTextArea textArea = (HtmlTextArea) inputElements.get(0);
+                textArea.setText(paramValue);
+            }
+        }
     }
 
     /**
@@ -604,14 +615,14 @@
         if (hasForm()) {
             for (int i = 0; i < getForms().size(); i++) {
                 HtmlForm form = (HtmlForm) getForms().get(i);
-                try {
-                    if (form.getInputByName(inputName) != null) {
-                        setWorkingForm(form);
-                        return form;
-                    }
-                } catch (ElementNotFoundException e) {
-                    // Nothing
+                List inputElements = form.getHtmlElementsByAttribute("input", 
"name", inputName);
+                if (inputElements.isEmpty()) {
+                    inputElements = form.getTextAreasByName(inputName);
                 }
+                if (!inputElements.isEmpty()) {
+                    setWorkingForm(form);
+                    return form;
+                }
             }
         }
         return null;
@@ -1477,4 +1488,4 @@
         return testContext;
     }
 
-}
\ No newline at end of file
+}

Modified: branches/1.x/pom.xml
===================================================================
--- branches/1.x/pom.xml        2006-07-11 15:26:37 UTC (rev 533)
+++ branches/1.x/pom.xml        2006-07-25 14:05:49 UTC (rev 534)
@@ -141,6 +141,16 @@
             <timezone />
             <properties />
         </contributor>
+        <contributor>
+            <name>Fred Burlet</name>
+            <email>[EMAIL PROTECTED]</email>
+            <url />
+            <organization />
+            <organizationUrl />
+            <roles />
+            <timezone />
+            <properties />
+        </contributor>
     </contributors>
     <licenses>
         <license>

Modified: branches/1.x/src/changes/changes.xml
===================================================================
--- branches/1.x/src/changes/changes.xml        2006-07-11 15:26:37 UTC (rev 
533)
+++ branches/1.x/src/changes/changes.xml        2006-07-25 14:05:49 UTC (rev 
534)
@@ -6,6 +6,9 @@
        </properties>
        <body>
         <release version="1.3-SNAPSHOT" date="UNKNOW">
+            <action type="fix" dev="Julien Henry" due-to="Fred Burlet">
+                setTextField is now working with TextArea.
+            </action>
             <action type="fix" dev="Julien Henry" due-to="Mark 
Chaimungkalanont">
                 Current form was saved but not reseted when page content 
change.
             </action>


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


-------------------------------------------------------------------------
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-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development

Reply via email to