Ok... First, I subscribed to dev mailing list and put it in the reception
field of this mail... and I say hello to all jwebunit developers :o)
A bit of summary what Julien and I were discussing about:
assertFormElementEquals does not support textarea. Julien suggested me another
solution. (see discussion below this mail).
Now I have several comments/ideas about Julien's feedback:
* I assume assertTextFieldEquals should cover textareas and not only input
text fields for consistency reasons.
* I don't see what assertHiddenFieldEquals could check ? We could add
assertHiddenFieldPresent(String inputName, String inputValue) ?
I will start implementing assertTextFieldEquals... let me know your point of
view about assertHiddenFieldEquals :o)
Regards,
Fred.
On Wednesday 26 July 2006 12:28, Julien HENRY wrote:
> Hum, I don't like assertFormElementEquals. I only leave it to preserve
> backward compatibility. I think we should provide more precise methods,
> like : - assertCheckBoxSelected
> - assertRadioOptionSelected
> - assertSelectedOptionEquals
> We could add :
> - assertTextFieldEquals
> - assertHiddenFieldEquals
>
> With all this methods, we could deprecated assertFormElementEquals in
> future releases.
>
> So, if you agree this point of view, could you please create the method
> assertTextFieldEquals?
>
> You can continue to send patch, but use dev mailing list, as I am not the
> only developper, and it allows the other to follow the evolutions of
> jWebUnit. Moreover, if you continue to work for jwebunit, you will be
> promoted committer very soon ;)
>
> ++
>
> Julien
>
> ----- Message d'origine ----
> De : Fred <[EMAIL PROTECTED]>
> À : Julien HENRY <[EMAIL PROTECTED]>
> Envoyé le : Mercredi, 26 Juillet 2006, 11h36mn 30s
> Objet : New patch
>
>
> Hi Julien,
>
> I'm still working with textareas and seen that something was missing in
> order to check the text of a textarea.
> I was using the method assertFormElementEquals which ended up by the
> RuntimeException. That's the reason why I sent you the first patch...
> At first glance, I though my test was wrong but after a bit of
> investigation, I didn't find a way to check the text of a textarea and that
> the method I was using (assertFormElementEquals) was the right one but
> incomplete.
> So I created a new patch and made a test case for that... You will find it
> out in attachment.
>
> Let me know if it is ok for you.
>
> Er... also... let me know if directly sending patches to you without
> discussing about the topic on the mailing list is ok for you :o) Or if you
> want me to process another way when I submit patches :o)
>
> Regards,
>
> Fred.
>
>
> *DISCLAIMER*
> This e-mail (including any attachments) may contain information which is
> privileged or confidential or constitute non-public information.It is to be
> conveyed only to the intended recipient(s).If you received this e-mail in
> error, please notify the sender immediately by e-mail or telephone and
> delete the e-mail from your system without reading, copying or disclosing
> its contents to any other person.
>
> Index:
> jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormAss
>ertionsTest.java
> =================================================================== ---
> jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormAss
>ertionsTest.java (revision 535) +++
> jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormAss
>ertionsTest.java (working copy) @@ -59,6 +59,8 @@
> beginAt("/testPage.html");
> assertPass("assertFormElementEquals", new
> Object[]{"testInputElement", "testValue"});
> assertPass("assertFormElementEquals", new Object[]{"submitButton",
> "buttonLabel"}); + assertPass("assertFormElementEquals", new
> Object[]{"textarea", "sometexthere"}); +
> assertPass("assertFormElementEquals", new Object[]{"cool", "dog"});
> assertFail("assertFormElementEquals", new Object[]{"testInputElement",
> "noSuchValue"}); assertFail("assertFormElementEquals", new
> Object[]{"noSuchElement", "testValue"}); }
> Index:
> jwebunit-commons-tests/src/main/resources/testcases/FormAssertionsTest/test
>Page.html
> =================================================================== ---
> jwebunit-commons-tests/src/main/resources/testcases/FormAssertionsTest/test
>Page.html (revision 535) +++
> jwebunit-commons-tests/src/main/resources/testcases/FormAssertionsTest/test
>Page.html (working copy) @@ -36,6 +36,7 @@
> <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></form> </td>
> </tr>
> </table>
> Index:
> jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/Ht
>mlUnitDialog.java
> =================================================================== ---
> jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/Ht
>mlUnitDialog.java (revision 535) +++
> jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/Ht
>mlUnitDialog.java (working copy) @@ -314,18 +314,23 @@
> HtmlRadioButtonInput rbtn =
> getForm().getCheckedRadioButton(paramName); if (rbtn != null)
> return rbtn.getValueAttribute();
> - try {
> - // TODO What should I return when it is a multi-select
> - return ((HtmlOption) getForm().getSelectByName(paramName)
> - .getSelectedOptions().get(0)).getValueAttribute();
> - } catch (ElementNotFoundException e) {
> -
> + List formElements = getForm().getSelectsByName(paramName);
> + // TODO What should I return when it is a multi-select
> + if (!formElements.isEmpty()) {
> + HtmlSelect selectElement = (HtmlSelect) formElements.get(0);
> + HtmlOption option = (HtmlOption)
> selectElement.getSelectedOptions().get(0); + return
> option.getValueAttribute();
> }
> - try {
> - return
> getForm().getInputByName(paramName).getValueAttribute(); - } catch
> (ElementNotFoundException e) {
> -
> + formElements = getForm().getHtmlElementsByAttribute("input",
> "name", paramName); + if (!formElements.isEmpty()) {
> + HtmlInput inputElement = (HtmlInput) formElements.get(0);
> + return inputElement.getValueAttribute();
> }
> + formElements = getForm().getTextAreasByName(paramName);
> + if (!formElements.isEmpty()) {
> + HtmlTextArea textAreaElement = (HtmlTextArea)
> formElements.get(0); + return textAreaElement.getText();
> + }
> throw new RuntimeException("getFormParameterValue failed");
> }
*DISCLAIMER*
This e-mail (including any attachments) may contain information which is
privileged or confidential or constitute non-public information.It is to be
conveyed only to the intended recipient(s).If you received this e-mail in
error, please notify the sender immediately by e-mail or telephone and delete
the e-mail from your system without reading, copying or disclosing its contents
to any other person.
-------------------------------------------------------------------------
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