Revision: 568
http://svn.sourceforge.net/jwebunit/?rev=568&view=rev
Author: henryju
Date: 2006-09-26 06:08:23 -0700 (Tue, 26 Sep 2006)
Log Message:
-----------
Fix bug [1565634] : selectOption reset previous setWorkingForm action. Add unit
test.
Update poms to 1.4-SNAPSHOT.
Modified Paths:
--------------
branches/1.x/jwebunit-commons-tests/pom.xml
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/MultiFormPage.html
branches/1.x/jwebunit-htmlunit-plugin/pom.xml
branches/1.x/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitDialog.java
branches/1.x/src/changes/changes.xml
Modified: branches/1.x/jwebunit-commons-tests/pom.xml
===================================================================
--- branches/1.x/jwebunit-commons-tests/pom.xml 2006-09-22 15:25:22 UTC (rev
567)
+++ branches/1.x/jwebunit-commons-tests/pom.xml 2006-09-26 13:08:23 UTC (rev
568)
@@ -17,12 +17,12 @@
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
- <version>6.0.0beta16</version>
+ <version>6.0.1</version>
</dependency>
<dependency>
<groupId>net.sourceforge.jwebunit</groupId>
<artifactId>jwebunit-core</artifactId>
- <version>1.3</version>
+ <version>1.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
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-09-22 15:25:22 UTC (rev 567)
+++
branches/1.x/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormSubmissionTest.java
2006-09-26 13:08:23 UTC (rev 568)
@@ -219,6 +219,14 @@
assertSelectedOptionEquals("select1", "two");
}
+ public void testSelectOptionInAnotherForm() {
+ beginAt("/MultiFormPage.html");
+ setWorkingForm("form6bis");
+ assertSelectedOptionEquals("select1", "four");
+ selectOption("select1", "five");
+ assertSelectedOptionEquals("select1", "five");
+ }
+
public void testSelectOptionByValue() {
beginAt("/MultiFormPage.html");
assertSelectedOptionValueEquals("select1", "1");
Modified:
branches/1.x/jwebunit-commons-tests/src/main/resources/testcases/FormSubmissionTest/MultiFormPage.html
===================================================================
---
branches/1.x/jwebunit-commons-tests/src/main/resources/testcases/FormSubmissionTest/MultiFormPage.html
2006-09-22 15:25:22 UTC (rev 567)
+++
branches/1.x/jwebunit-commons-tests/src/main/resources/testcases/FormSubmissionTest/MultiFormPage.html
2006-09-26 13:08:23 UTC (rev 568)
@@ -37,6 +37,14 @@
</select>
</form>
+ <form id="form6bis">
+ <select name="select1">
+ <option value="1">four</option>
+ <option value="2">five</option>
+ <option value="3">six</option>
+ </select>
+ </form>
+
<form name="myForm">
<input type="submit" name="myInput1">
</form>
Modified: branches/1.x/jwebunit-htmlunit-plugin/pom.xml
===================================================================
--- branches/1.x/jwebunit-htmlunit-plugin/pom.xml 2006-09-22 15:25:22 UTC
(rev 567)
+++ branches/1.x/jwebunit-htmlunit-plugin/pom.xml 2006-09-26 13:08:23 UTC
(rev 568)
@@ -98,12 +98,12 @@
<dependency>
<groupId>net.sourceforge.jwebunit</groupId>
<artifactId>jwebunit-core</artifactId>
- <version>1.3</version>
+ <version>1.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.sourceforge.jwebunit</groupId>
<artifactId>jwebunit-commons-tests</artifactId>
- <version>1.3</version>
+ <version>1.4-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
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-09-22 15:25:22 UTC (rev 567)
+++
branches/1.x/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitDialog.java
2006-09-26 13:08:23 UTC (rev 568)
@@ -330,20 +330,23 @@
}
throw new RuntimeException("getFormParameterValue failed");
}
-
+
/**
- * Return the current value of a text input element with name
<code>paramName</code>.
+ * Return the current value of a text input element with name
+ * <code>paramName</code>.
*
* @param paramName
- * name of the input element.
- * TODO: Find a way to handle multiple text input element with same name.
+ * name of the input element. TODO: Find a way to handle
multiple
+ * text input element with same name.
*/
public String getTextFieldValue(String paramName) {
checkFormStateWithInput(paramName);
- List textFieldElements = getForm().getHtmlElementsByAttribute("input",
"type", "text");
- textFieldElements.addAll(getForm().getHtmlElementsByAttribute("input",
"type", "password"));
+ List textFieldElements = getForm().getHtmlElementsByAttribute("input",
+ "type", "text");
+ textFieldElements.addAll(getForm().getHtmlElementsByAttribute("input",
+ "type", "password"));
Iterator it = textFieldElements.iterator();
- while(it.hasNext()) {
+ while (it.hasNext()) {
HtmlInput input = (HtmlInput) it.next();
if (paramName.equals(input.getNameAttribute())) {
return input.getValueAttribute();
@@ -352,37 +355,44 @@
// If no text field with the name paramName then try with textareas.
textFieldElements = getForm().getTextAreasByName(paramName);
it = textFieldElements.iterator();
- while(it.hasNext()) {
+ while (it.hasNext()) {
HtmlTextArea textInput = (HtmlTextArea) it.next();
if (paramName.equals(textInput.getNameAttribute())) {
return textInput.getText();
}
}
- throw new RuntimeException("getTextFieldParameterValue failed, text
field with name [" + paramName + "] does not exist.");
+ throw new RuntimeException(
+ "getTextFieldParameterValue failed, text field with name ["
+ + paramName + "] does not exist.");
}
/**
- * Return the current value of a hidden input element with name
<code>paramName</code>.
+ * Return the current value of a hidden input element with name
+ * <code>paramName</code>.
*
* @param paramName
- * name of the input element.
- * TODO: Find a way to handle multiple hidden input element with same
name.
+ * name of the input element. TODO: Find a way to handle
multiple
+ * hidden input element with same name.
*/
public String getHiddenFieldValue(String paramName) {
checkFormStateWithInput(paramName);
- List textFieldElements = getForm().getHtmlElementsByAttribute("input",
"type", "hidden");
+ List textFieldElements = getForm().getHtmlElementsByAttribute("input",
+ "type", "hidden");
Iterator it = textFieldElements.iterator();
- while(it.hasNext()) {
+ while (it.hasNext()) {
HtmlHiddenInput textInput = (HtmlHiddenInput) it.next();
if (paramName.equals(textInput.getNameAttribute())) {
return textInput.getValueAttribute();
}
}
- throw new RuntimeException("getHiddenFieldParameterValue failed,
hidden field with name [" + paramName + "] does not exist.");
+ throw new RuntimeException(
+ "getHiddenFieldParameterValue failed, hidden field with name ["
+ + paramName + "] does not exist.");
}
/**
- * Set a form text, password input element or textarea to the provided
value.
+ * Set a form text, password input element or textarea to the provided
+ * value.
*
* @param fieldName
* name of the input element or textarea
@@ -391,7 +401,8 @@
*/
public void setTextField(String fieldName, String paramValue) {
checkFormStateWithInput(fieldName);
- List inputElements = getForm().getHtmlElementsByAttribute("input",
"name", fieldName);
+ List inputElements = getForm().getHtmlElementsByAttribute("input",
+ "name", fieldName);
if (!inputElements.isEmpty()) {
HtmlInput input = (HtmlInput) inputElements.get(0);
input.setValueAttribute(paramValue);
@@ -667,7 +678,8 @@
if (hasForm()) {
for (int i = 0; i < getForms().size(); i++) {
HtmlForm form = (HtmlForm) getForms().get(i);
- List inputElements = form.getHtmlElementsByAttribute("input",
"name", inputName);
+ List inputElements = form.getHtmlElementsByAttribute("input",
+ "name", inputName);
if (inputElements.isEmpty()) {
inputElements = form.getTextAreasByName(inputName);
}
@@ -681,16 +693,27 @@
}
private HtmlForm getFormWithSelect(String selectName) {
- 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;
+ // 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
}
- } catch (ElementNotFoundException e) {
- // Nothing
}
}
}
@@ -904,7 +927,7 @@
public HtmlButton getButtonWithText(String buttonValueText) {
List l = ((HtmlPage) win.getEnclosedPage()).getDocumentElement()
.getHtmlElementsByTagNames(
- Arrays.asList(new String[] { "button" }));
+ Arrays.asList(new String[] {"button"}));
for (int i = 0; i < l.size(); i++) {
HtmlElement e = (HtmlElement) l.get(i);
if (((HtmlButton) e).getValueAttribute().equals(buttonValueText))
Modified: branches/1.x/src/changes/changes.xml
===================================================================
--- branches/1.x/src/changes/changes.xml 2006-09-22 15:25:22 UTC (rev
567)
+++ branches/1.x/src/changes/changes.xml 2006-09-26 13:08:23 UTC (rev
568)
@@ -5,6 +5,11 @@
<author email="dashorst at users.sourceforge.net">Martijn
Dashorst</author>
</properties>
<body>
+ <release version="1.4" date="UNKNOW">
+ <action type="fix" dev="Julien Henry" due-to="Veenay Dodia"
issue="1565634">
+ selectOption() reset previous setWorkingForm() action.
Problematic with 2 selects with same name in 2 different forms.
+ </action>
+ </release>
<release version="1.3" date="july 28, 2006">
<action type="remove" dev="Julien Henry" due-to="Fred Burlet">
assertFormParameterValue is now deprecated. Please use more
specific method, like
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