Revision: 578
http://svn.sourceforge.net/jwebunit/?rev=578&view=rev
Author: henryju
Date: 2006-10-12 08:49:36 -0700 (Thu, 12 Oct 2006)
Log Message:
-----------
Feature Request 1575956 : add assertCheckboxSelected(name, value)
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/resources/testcases/FormAssertionsTest/testPage.html
branches/1.x/jwebunit-core/src/main/java/net/sourceforge/jwebunit/IJWebUnitDialog.java
branches/1.x/jwebunit-core/src/main/java/net/sourceforge/jwebunit/WebTestCase.java
branches/1.x/jwebunit-core/src/main/java/net/sourceforge/jwebunit/WebTester.java
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/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-10-12 07:15:53 UTC (rev 577)
+++
branches/1.x/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormAssertionsTest.java
2006-10-12 15:49:36 UTC (rev 578)
@@ -76,12 +76,26 @@
assertFail("assertCheckboxSelected", "nosuchbox");
}
+ public void testCheckboxSelectedByName() throws Throwable {
+ beginAt("/testPage.html");
+ assertPassFail("assertCheckboxSelected", new
Object[]{"checkboxnotselected", "actuallyselected"},
+ new
Object[]{"checkboxselected", "actuallynotselected"});
+ assertFail("assertCheckboxSelected", new Object[]{"checkboxselected",
"nosuchvalue"});
+ }
+
public void testCheckboxNotSelected() throws Throwable {
beginAt("/testPage.html");
assertPassFail("assertCheckboxNotSelected", "checkboxnotselected",
"checkboxselected");
assertFail("assertCheckboxNotSelected", "nosuchbox");
}
+ public void testCheckboxNotSelectedByName() throws Throwable {
+ beginAt("/testPage.html");
+ assertPassFail("assertCheckboxNotSelected", new
Object[]{"checkboxselected", "actuallynotselected"},
+ new
Object[]{"checkboxnotselected", "actuallyselected"});
+ assertFail("assertCheckboxNotSelected", new
Object[]{"checkboxnotselected", "nosuchvalue"});
+ }
+
public void testAssertSubmitButtonPresent() throws Throwable {
beginAt("/testPage.html");
assertPassFail("assertSubmitButtonPresent", "submitButton",
"noSuchButton");
Modified:
branches/1.x/jwebunit-commons-tests/src/main/resources/testcases/FormAssertionsTest/testPage.html
===================================================================
---
branches/1.x/jwebunit-commons-tests/src/main/resources/testcases/FormAssertionsTest/testPage.html
2006-10-12 07:15:53 UTC (rev 577)
+++
branches/1.x/jwebunit-commons-tests/src/main/resources/testcases/FormAssertionsTest/testPage.html
2006-10-12 15:49:36 UTC (rev 578)
@@ -4,43 +4,48 @@
</head>
<body>
<table summary="testTable">
- <tr>
- <td>table text</td>
- </tr>
- <tr>
- <td>table text row 2</td>
- </tr>
- <tr>
- <td>table text row 3</td>
- <td>row 3 col 1</td>
- <td><a href="someurl.html">test link</a>
- <form id="form1"><input type="button" id="b1" /> <select
- name="selectOption">
- <option value="1">One</option>
- <option value="2">Two</option>
- <option value="3">Three</option>
- </select> Test Input : <input type="text"
name="testInputElement"
- value="testValue" /> Test Input 2: <input type="text"
- name="testInputElement2" value="" /> <input
type="submit"
- name="submitButton" value="buttonLabel" /> <input
type="checkbox"
- name="checkboxselected" CHECKED> <input type="checkbox"
- name="checkboxnotselected"> <textarea name="text"
cols="44" rows="3"
- wrap="VIRTUAL"></textarea></form>
- <form name="form2"></form>
- <form id="form3"><input type="radio" name="cool" value="dog"
- checked="checked" /> <input type="radio" name="cool"
value="cat" />
- <input type="radio" name="cool" value="chicken" /></form>
- <form id="form4"><select name="select1">
- <option value="1">one</option>
- <option value="2">two</option>
- <option value="3">three</option>
- <option value="4">four</option>
- </select> <input type="reset" name="resetButton" /></form>
- <form id="form5"><textarea
name="textarea">sometexthere</textarea>
- <input type="hidden" name="hiddenelement" value="hiddenvalue"/>
- <input type="password" name="passwordelement"
value="password"></form>
- </td>
- </tr>
+ <tr>
+ <td>table text</td>
+ </tr>
+ <tr>
+ <td>table text row 2</td>
+ </tr>
+ <tr>
+ <td>table text row 3</td>
+ <td>row 3 col 1</td>
+ <td><a href="someurl.html">test link</a>
+ <form id="form1"><input type="button" id="b1" /> <select
+ name="selectOption">
+ <option value="1">One</option>
+ <option value="2">Two</option>
+ <option value="3">Three</option>
+ </select> Test Input : <input type="text" name="testInputElement"
+ value="testValue" /> Test Input 2: <input type="text"
+ name="testInputElement2" value="" /> <input type="submit"
+ name="submitButton" value="buttonLabel" /> <input
+ type="checkbox" name="checkboxselected" CHECKED>
+ <input
+ type="checkbox" name="checkboxselected"
value="actuallynotselected"> <input
+ type="checkbox" name="checkboxnotselected">
+ <input
+ type="checkbox" name="checkboxnotselected"
value="actuallyselected" CHECKED> <textarea
+ name="text" cols="44" rows="3" wrap="VIRTUAL"></textarea></form>
+ <form name="form2"></form>
+ <form id="form3"><input type="radio" name="cool"
+ value="dog" checked="checked" /> <input type="radio"
+ name="cool" value="cat" /> <input type="radio" name="cool"
+ value="chicken" /></form>
+ <form id="form4"><select name="select1">
+ <option value="1">one</option>
+ <option value="2">two</option>
+ <option value="3">three</option>
+ <option value="4">four</option>
+ </select> <input type="reset" name="resetButton" /></form>
+ <form id="form5"><textarea name="textarea">sometexthere</textarea>
+ <input type="hidden" name="hiddenelement" value="hiddenvalue" />
+ <input type="password" name="passwordelement" value="password"></form>
+ </td>
+ </tr>
</table>
</body>
</html>
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-10-12 07:15:53 UTC (rev 577)
+++
branches/1.x/jwebunit-core/src/main/java/net/sourceforge/jwebunit/IJWebUnitDialog.java
2006-10-12 15:49:36 UTC (rev 578)
@@ -306,14 +306,25 @@
/**
* Determines if the checkbox is selected.
- *
+ *
* @param checkBoxName
* name of the checkbox.
- * @return true if the checkbox is selected.
+ * @return true if the first checkbox with given name is selected.
*/
boolean isCheckboxSelected(String checkBoxName);
/**
+ * Determines if the checkbox is selected.
+ *
+ * @param checkBoxName
+ * name attribut of the checkbox.
+ * @param checkBoxValue
+ * value attribut of the checkbox.
+ * @return true if the first checkbox with given name and value is
selected.
+ */
+ boolean isCheckboxSelected(String checkBoxName, String checkBoxValue);
+
+ /**
* Select a specified checkbox. If the checkbox is already checked then the
* checkbox will stay checked.
*
@@ -328,11 +339,11 @@
*
* @param checkBoxName
* name of checkbox to be selected.
- * @param value
+ * @param checkBoxValue
* value of the checkbox (to differenciate checkboxes with the
* same name).
*/
- void checkCheckbox(String checkBoxName, String value);
+ void checkCheckbox(String checkBoxName, String checkBoxValue);
/**
* Deselect a specified checkbox. If the checkbox is already unchecked then
Modified:
branches/1.x/jwebunit-core/src/main/java/net/sourceforge/jwebunit/WebTestCase.java
===================================================================
---
branches/1.x/jwebunit-core/src/main/java/net/sourceforge/jwebunit/WebTestCase.java
2006-10-12 07:15:53 UTC (rev 577)
+++
branches/1.x/jwebunit-core/src/main/java/net/sourceforge/jwebunit/WebTestCase.java
2006-10-12 15:49:36 UTC (rev 578)
@@ -296,10 +296,18 @@
getTester().assertCheckboxSelected(checkBoxName);
}
+ public void assertCheckboxSelected(String checkBoxName, String
checkBoxValue) {
+ getTester().assertCheckboxSelected(checkBoxName, checkBoxValue);
+ }
+
public void assertCheckboxNotSelected(String checkBoxName) {
getTester().assertCheckboxNotSelected(checkBoxName);
}
+ public void assertCheckboxNotSelected(String checkBoxName, String
checkBoxValue) {
+ getTester().assertCheckboxNotSelected(checkBoxName, checkBoxValue);
+ }
+
public void assertRadioOptionPresent(String radioGroup, String
radioOption) {
getTester().assertRadioOptionPresent(radioGroup, radioOption);
}
Modified:
branches/1.x/jwebunit-core/src/main/java/net/sourceforge/jwebunit/WebTester.java
===================================================================
---
branches/1.x/jwebunit-core/src/main/java/net/sourceforge/jwebunit/WebTester.java
2006-10-12 07:15:53 UTC (rev 577)
+++
branches/1.x/jwebunit-core/src/main/java/net/sourceforge/jwebunit/WebTester.java
2006-10-12 15:49:36 UTC (rev 578)
@@ -664,6 +664,21 @@
}
/**
+ * Assert that a given checkbox is present.
+ *
+ * @param checkboxName
+ * checkbox name attribut.
+ * @param checkboxValue
+ * checkbox value attribut.
+ */
+ public void assertCheckboxPresent(String checkboxName, String
checkboxValue) {
+ assertFormPresent();
+ Assert.assertTrue("Did not find form checkbox with name ["
+ + checkboxName + "] and value [" + checkboxValue + "].",
getDialog().hasElementByXPath(
+ "//[EMAIL PROTECTED]'checkbox' and @name='" + checkboxName +
"' and @value='" + checkboxValue + "']"));
+ }
+
+ /**
* Assert that a form checkbox with a given name is not present.
*
* @param checkboxName
@@ -677,6 +692,21 @@
}
/**
+ * Assert that a given checkbox is not present.
+ *
+ * @param checkboxName
+ * checkbox name.
+ * @param checkboxValue
+ * checkbox value attribut.
+ */
+ public void assertCheckboxNotPresent(String checkboxName, String
checkboxValue) {
+ assertFormPresent();
+ Assert.assertFalse("Found form checkbox with name [" + checkboxName
+ + "] and value [" + checkboxValue + "] when not expected.",
getDialog().hasElementByXPath(
+ "//[EMAIL PROTECTED]'checkbox' and @name='" + checkboxName +
"' and @value='" + checkboxValue + "']"));
+ }
+
+ /**
* Assert that there is a form present.
*
*/
@@ -799,6 +829,20 @@
}
/**
+ * Assert that a specific checkbox is selected.
+ *
+ * @param checkBoxName
+ * @param checkBoxValue
+ */
+ public void assertCheckboxSelected(String checkBoxName, String
checkBoxValue) {
+ assertCheckboxPresent(checkBoxName, checkBoxValue);
+ if (!getDialog().isCheckboxSelected(checkBoxName, checkBoxValue)) {
+ Assert.fail("Checkbox with name [" + checkBoxName
+ + "] and value [" + checkBoxValue + "] was not found
selected.");
+ }
+ }
+
+ /**
* Assert that a specific checkbox is not selected.
*
* @param checkBoxName
@@ -812,6 +856,20 @@
}
/**
+ * Assert that a specific checkbox is not selected.
+ *
+ * @param checkBoxName
+ * @param checkBoxValue
+ */
+ public void assertCheckboxNotSelected(String checkBoxName, String
checkBoxValue) {
+ assertCheckboxPresent(checkBoxName, checkBoxValue);
+ if (getDialog().isCheckboxSelected(checkBoxName, checkBoxValue)) {
+ Assert.fail("Checkbox with name [" + checkBoxName
+ + "] and value [" + checkBoxValue + "] was found
selected.");
+ }
+ }
+
+ /**
* Assert that a specific option is present in a radio group.
*
* @param name
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-10-12 07:15:53 UTC (rev 577)
+++
branches/1.x/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitDialog.java
2006-10-12 15:49:36 UTC (rev 578)
@@ -956,9 +956,9 @@
return cb.isChecked();
}
- public boolean isCheckboxNotSelected(String checkBoxName) {
- HtmlCheckBoxInput cb = getCheckbox(checkBoxName);
- return !cb.isChecked();
+ public boolean isCheckboxSelected(String checkBoxName, String
checkBoxValue) {
+ HtmlCheckBoxInput cb = getCheckbox(checkBoxName, checkBoxValue);
+ return cb.isChecked();
}
/**
Modified: branches/1.x/src/changes/changes.xml
===================================================================
--- branches/1.x/src/changes/changes.xml 2006-10-12 07:15:53 UTC (rev
577)
+++ branches/1.x/src/changes/changes.xml 2006-10-12 15:49:36 UTC (rev
578)
@@ -8,6 +8,11 @@
</properties>
<body>
<release version="1.4" date="UNKNOW">
+ <action type="add" dev="Julien Henry" due-to="Lasse Koskela"
+ issue="1575956">
+ Add new methods: assertCheckBox[Not]Selected(String name,
String value)
+ to deal with multiple checkboxes with the same name.
+ </action>
<action type="fix" dev="Julien Henry" due-to="Jack"
issue="1567947">
assertButtonPresentWithText(String) was checking on
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