Revision: 705
          http://svn.sourceforge.net/jwebunit/?rev=705&view=rev
Author:   henryju
Date:     2007-05-05 14:53:59 -0700 (Sat, 05 May 2007)

Log Message:
-----------
[Issue 1708229,1710809,1712633] Fix getFormWithInput to deal with the current 
working form if already set.

Modified Paths:
--------------
    
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormAssertionsTest.java
    
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormSubmissionTest.java
    
trunk/jwebunit-commons-tests/src/main/resources/testcases/FormSubmissionTest/MultiFormPage.html
    trunk/jwebunit-core/pom.xml
    
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
    trunk/src/changes/changes.xml

Modified: 
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormAssertionsTest.java
===================================================================
--- 
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormAssertionsTest.java
   2007-05-05 21:06:44 UTC (rev 704)
+++ 
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormAssertionsTest.java
   2007-05-05 21:53:59 UTC (rev 705)
@@ -57,17 +57,19 @@
 
     public void testAssertFormElementEquals() throws Throwable {
         beginAt("/testPage.html");
-        assertPass("assertTextFieldEquals", new Object[]{"testInputElement", 
"testValue"});
+        assertPassFail("assertTextFieldEquals", new 
Object[]{"testInputElement", "testValue"}, new Object[]{"testInputElement", 
"noSuchValue"});
         assertPass("assertSubmitButtonPresent", new Object[]{"submitButton", 
"buttonLabel"});
+        setWorkingForm("form5");
         assertPass("assertTextFieldEquals", new Object[]{"textarea", 
"sometexthere"});
+        setWorkingForm("form3");
         assertPass("assertRadioOptionSelected", new Object[]{"cool", "dog"});
-        assertPass("assertHiddenFieldPresent", new Object[]{"hiddenelement", 
"hiddenvalue"});
-        assertFail("assertTextFieldEquals", new Object[]{"testInputElement", 
"noSuchValue"});
+        setWorkingForm("form5");
+        assertPassFail("assertHiddenFieldPresent", new 
Object[]{"hiddenelement", "hiddenvalue"}, new Object[]{"hiddenelement", 
"notThisValue"});
+        setWorkingForm("form1");
         assertFail("assertTextFieldEquals", new Object[]{"noSuchElement", 
"testValue"});
         assertFail("assertHiddenFieldPresent", new Object[]{"noSuchElement", 
"testValue"});
-        assertFail("assertHiddenFieldPresent", new Object[]{"hiddenelement", 
"notThisValue"});
-        assertFail("assertTextFieldEquals", new Object[]{"passwordelement", 
"noSuchValue"});
-        assertPass("assertTextFieldEquals", new Object[]{"passwordelement", 
"password"});
+        setWorkingForm("form5");        
+        assertPassFail("assertTextFieldEquals", new 
Object[]{"passwordelement", "password"}, new Object[]{"passwordelement", 
"noSuchValue"});
     }
 
     public void testCheckboxSelected() throws Throwable {

Modified: 
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormSubmissionTest.java
===================================================================
--- 
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormSubmissionTest.java
   2007-05-05 21:06:44 UTC (rev 704)
+++ 
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormSubmissionTest.java
   2007-05-05 21:53:59 UTC (rev 705)
@@ -196,6 +196,24 @@
         assertTextPresent("param2=anyvalue");
     }
 
+    public void testTextFieldSetOnMultiFormWithSameName() {
+        beginAt("/MultiFormPage.html");
+        setWorkingForm("form2");
+        setTextField("param2", "foo");
+        setTextField("email", "anyvalue");
+        submit();
+        assertTextPresent("email=anyvalue");
+        assertTextPresent("param2=foo");
+        closeBrowser();
+        beginAt("/MultiFormPage.html");
+        setWorkingForm("form3");
+        setTextField("param3", "foo");
+        setTextField("email", "anyvalue");
+        submit();
+        assertTextPresent("param3=foo");
+        assertTextPresent("email=anyvalue");
+    }
+
     public void testSetWorkingFormById() {
         beginAt("/MultiFormPage.html");
         setWorkingForm("form5");

Modified: 
trunk/jwebunit-commons-tests/src/main/resources/testcases/FormSubmissionTest/MultiFormPage.html
===================================================================
--- 
trunk/jwebunit-commons-tests/src/main/resources/testcases/FormSubmissionTest/MultiFormPage.html
     2007-05-05 21:06:44 UTC (rev 704)
+++ 
trunk/jwebunit-commons-tests/src/main/resources/testcases/FormSubmissionTest/MultiFormPage.html
     2007-05-05 21:53:59 UTC (rev 705)
@@ -10,6 +10,7 @@
 
                <form name="form2" method=GET action="../params.jsp">
                        <input type="text" name="param2">
+                       <input type="text" name="email">
             <input type="reset">
                        <input type="submit" name="button2a" value="b2a">
                        <input type="submit" name="button2b" value="b2b">
@@ -18,6 +19,7 @@
 
                <form name="form3" method=GET action="../params.jsp">
                        <input type="text" name="param3">
+                       <input type="text" name="email">
                        <input type="submit">
                        <input type="hidden" name="myReferer" 
value="FormSubmissionTest/MultiFormPage.html">
                </form>

Modified: trunk/jwebunit-core/pom.xml
===================================================================
--- trunk/jwebunit-core/pom.xml 2007-05-05 21:06:44 UTC (rev 704)
+++ trunk/jwebunit-core/pom.xml 2007-05-05 21:53:59 UTC (rev 705)
@@ -15,6 +15,7 @@
                <dependency>
                        <groupId>junit</groupId>
                        <artifactId>junit</artifactId>
+            <scope>test</scope>
                </dependency>
                <dependency>
                        <groupId>regexp</groupId>
@@ -27,52 +28,5 @@
        </dependencies>
        <properties>
                <topDirectoryLocation>..</topDirectoryLocation>
-       </properties>
-       <build>
-               <plugins>
-                       <plugin>
-                               <groupId>org.codehaus.mojo</groupId>
-                               <artifactId>exec-maven-plugin</artifactId>
-                               <executions>
-                                       <execution>
-                                               <phase>generate-sources</phase>
-                                               <goals>
-                                                       <goal>java</goal>
-                                               </goals>
-                                               <configuration>
-                                                       <sourceRoot>
-                                                               
${project.build.directory}/generated-sources/main/java
-                                                       </sourceRoot>
-                                               </configuration>
-                                       </execution>
-                               </executions>
-                               <configuration>
-                                       <mainClass>
-                                               
net.sourceforge.jwebunit.javacc.WebTestCaseGenerator
-                                       </mainClass>
-                                       <arguments>
-                                               
<argument>${basedir}/src/main/java</argument>
-                                               <argument>
-                                                       
${project.build.directory}/generated-sources/main/java
-                                               </argument>
-                                       </arguments>
-                                       <includePluginDependencies>
-                                               true
-                                       </includePluginDependencies>
-                                       <includeProjectDependencies>
-                                               false
-                                       </includeProjectDependencies>
-                               </configuration>
-                               <dependencies>
-                                       <dependency>
-                                               
<groupId>net.sourceforge.jwebunit</groupId>
-                                               <artifactId>
-                                                       
jwebunit-webtestcase-generator
-                                               </artifactId>
-                                               
<version>${project.parent.version}</version>
-                                       </dependency>
-                               </dependencies>
-                       </plugin>
-               </plugins>
-       </build>
+       </properties>   
 </project>
\ No newline at end of file

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
       2007-05-05 21:06:44 UTC (rev 704)
+++ 
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
       2007-05-05 21:53:59 UTC (rev 705)
@@ -896,18 +896,29 @@
     }
 
     private HtmlForm getFormWithInput(String inputName) {
-        if (hasForm()) {
-            for (int i = 0; i < getForms().size(); i++) {
-                HtmlForm form = (HtmlForm) getForms().get(i);
-                List inputElements = form.getHtmlElementsByAttribute("input",
-                        "name", inputName);
-                if (inputElements.isEmpty()) {
-                    inputElements = form.getTextAreasByName(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 (int i = 0; i < getForms().size(); i++) {
+                    HtmlForm form = (HtmlForm) getForms().get(i);
+                    List inputElements = 
form.getHtmlElementsByAttribute("input",
+                            "name", inputName);
+                    if (inputElements.isEmpty()) {
+                        inputElements = form.getTextAreasByName(inputName);
+                    }
+                    if (!inputElements.isEmpty()) {
+                        setWorkingForm(form);
+                        return form;
+                    }
                 }
-                if (!inputElements.isEmpty()) {
-                    setWorkingForm(form);
-                    return form;
-                }
             }
         }
         return null;

Modified: trunk/src/changes/changes.xml
===================================================================
--- trunk/src/changes/changes.xml       2007-05-05 21:06:44 UTC (rev 704)
+++ trunk/src/changes/changes.xml       2007-05-05 21:53:59 UTC (rev 705)
@@ -8,10 +8,20 @@
     </properties>
     <body>
        <release version="1.5" date="UNKNOW">
+            <action type="add" dev="Julien Henry">
+                Add basic Selenium support.
+            </action>
             <action type="update" dev="Julien Henry">
                 Rename IJWebUnitDialog in ITestingEngine.
             </action>
        </release>
+       <release version="1.4.1" date="may 5, 2007">
+               <action type="fix" dev="Julien Henry" 
issue="1708229,1710809,1712633" due-to="Jon,Joe Fisher">
+                setTextField now doesn't change the current working form if 
already set.
+                clickRadioOption now doesn't change the current working form 
if already set.
+                assertFormElementPresent now only searches the current working 
form if already set.
+            </action>
+       </release>
        <release version="1.4" date="march 17, 2007">
                <action type="update" dev="Julien Henry">
                 Update to HtmlUnit 1.11.


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

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
JWebUnit-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development

Reply via email to