Update of /cvsroot/jwebunit/jWebUnit/src/net/sourceforge/jwebunit/plugin/jacobie
In directory
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2487/src/net/sourceforge/jwebunit/plugin/jacobie
Modified Files:
JacobieDialog.java
Log Message:
implementing more methods in response to UnSuppOpException.
Index: JacobieDialog.java
===================================================================
RCS file:
/cvsroot/jwebunit/jWebUnit/src/net/sourceforge/jwebunit/plugin/jacobie/JacobieDialog.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** JacobieDialog.java 5 Mar 2005 17:54:19 -0000 1.3
--- JacobieDialog.java 9 Mar 2005 06:08:02 -0000 1.4
***************
*** 267,272 ****
return bReturn;
}
-
-
public boolean hasSubmitButton(String aButtonName) {
--- 267,270 ----
***************
*** 585,588 ****
--- 583,606 ----
}
+ /**
+ * Return true if a select box has the given option (by label).
+ *
+ * @param selectName
+ * name of the select box.
+ * @param optionLabel
+ * label of the option.
+ * @return
+ */
+ public boolean hasSelectOption(String selectName, String optionLabel) {
+ boolean bReturn = false;
+
+ String theString = getValueForOption(selectName, optionLabel);
+ if(theString != null) {
+ //if the value is return then the option with the label must
exist.
+ bReturn = true;
+ }
+ return bReturn;
+ }
+
/**
* Select an option of a select box by display label.
***************
*** 596,602 ****
--- 614,660 ----
setFormParameter(selectName, getValueForOption(selectName,
option));
}
+
+ /**
+ * Return the label of the currently selected item in a select box.
+ *
+ * @param selectName
+ * name of the select box.
+ */
+ public String getSelectedOption(String selectName) {
+ String theString = null;
+ Select theSelect = getSelect(selectName);
+ if(theSelect != null && theSelect.hasSelectedOption()) {
+ theString = theSelect.getSelectedOption().getText();
+ }
+ return theString;
+ }
+
+ /**
+ * Gets the first select from the first form that has the select.
+ * @param selectName
+ * @return
+ */
+ public Select getSelect(String selectName) {
+ Select theSelect = null;
+ Document theDocument = getIe().getDocument();
+ if(theDocument != null) {
+ if(theDocument.hasForms()) {
+ ListIterator theFormsIterator =
theDocument.getForms().listIterator();
+ while (theFormsIterator.hasNext()) {
+ Form theForm = (Form) theFormsIterator.next();
+ Select theNextSelect = theForm.getSelect(selectName);
+ if(theNextSelect != null) {
+ theSelect = theNextSelect;
+ break;
+ }
+ }
+ }
+ }
+ return theSelect;
+ }
/**
* Get the value for a given option of a select box.
+ * <option value="1">one</option> Returns the "1" value.
*
* @param selectName
***************
*** 607,629 ****
public String getValueForOption(String selectName, String aText) {
String theValue = null;
! Document theDocument = getIe().getDocument();
! if(theDocument != null) {
! if(theDocument.hasForms()) {
! ListIterator theFormsIterator =
theDocument.getForms().listIterator();
! while (theFormsIterator.hasNext()) {
! Form theForm = (Form) theFormsIterator.next();
! Select theSelect = theForm.getSelect(selectName);
! if(theSelect != null) {
! if(theSelect.hasOptionBasedOnText(aText)) {
! theValue =
theSelect.getOptionBasedOnText(aText).getValue();
! }
! }
! }
}
}
- if(theValue == null) {
- throw new RuntimeException("Unable to find option " + aText + "
for " + selectName);
- }
-
return theValue;
}
--- 665,674 ----
public String getValueForOption(String selectName, String aText) {
String theValue = null;
! Select theSelect = getSelect(selectName);
! if(theSelect != null) {
! if(theSelect.hasOptionBasedOnText(aText)) {
! theValue = theSelect.getOptionBasedOnText(aText).getValue();
}
}
return theValue;
}
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Jwebunit-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development