In fact, it's how HtmlUnit works. You have to manipulate a great number of variable:
WebClient wc = new WebClient();
HtmlPage myPage = wc.getPage("www.google.fr");
HtmlForm form = (HtmlForm) myPage.getForms().get(0);
...
And the code become totally unreadable (there are also a lot of try..catch blocks). That's why jWebUnit was created. You don't need to manipulate variables. The current state is stored and you navigate in windows, frames and forms:
gotoPage("www.google.fr"); // The current page become www.google.fr
setCurrentForm(0); // The current form become 1rst form in current page
assertSubmitButtonPresent(); // Assert there is a submit button in the current form
The problem with manipulating objects with jWebUnit is that these objects should be independent of the plugins. Consequently, we would have to write a new layer, and it's very difficult. An example is html tables. Currently, we can get a jWebUnit object called Table from the plugin, but I don't think it's the best solution. Indeed, this object only store text content, colspan and rowspan of each cells.
A recent feature request was to assert a link is present in a given cell. With the current Table object, it's not possible.
Perhaps should we refactor the API to have the same logic as windows, frames or forms:
setCurrentTable(String tableNameSummaryOrId)
setCurrentCell(int row, int col);
++
Julien
WebClient wc = new WebClient();
HtmlPage myPage = wc.getPage("www.google.fr");
HtmlForm form = (HtmlForm) myPage.getForms().get(0);
...
And the code become totally unreadable (there are also a lot of try..catch blocks). That's why jWebUnit was created. You don't need to manipulate variables. The current state is stored and you navigate in windows, frames and forms:
gotoPage("www.google.fr"); // The current page become www.google.fr
setCurrentForm(0); // The current form become 1rst form in current page
assertSubmitButtonPresent(); // Assert there is a submit button in the current form
The problem with manipulating objects with jWebUnit is that these objects should be independent of the plugins. Consequently, we would have to write a new layer, and it's very difficult. An example is html tables. Currently, we can get a jWebUnit object called Table from the plugin, but I don't think it's the best solution. Indeed, this object only store text content, colspan and rowspan of each cells.
A recent feature request was to assert a link is present in a given cell. With the current Table object, it's not possible.
Perhaps should we refactor the API to have the same logic as windows, frames or forms:
setCurrentTable(String tableNameSummaryOrId)
setCurrentCell(int row, int col);
++
Julien
----- Message d'origine
----
De : Frédéric Burlet <[EMAIL PROTECTED]>
À : Julien HENRY <[EMAIL PROTECTED]>; Usage problems for jWebUnit <[email protected]>
Envoyé le : Samedi, 8 Juillet 2006, 12h41mn 08s
Objet : RE: Re : [Jwebunit-users] Ideas
Hi Julien,
I will file a feature request for my suggestions... later after the week-end
:)
Now, about my implementation of assertLabeled**, I was using
assertElementPresentByXPath because that's the only way I found to write
these implementations based on jWebUnit.
If you want to include these methods in the set of basic ones, I would
suggest you to implement these methods based on the core plugin library. I
mean, in the jWebUnit-htmlunit-plugin, the implementation should be based on
htmlunit or another way around if not possible. Beside, you should let the
assertElementPresentByXPath available to users for the specific/weird cases.
In fact, I don't know how htmlunit is working... and I'm only guessing how
jWebUnit is working based on the documentation and the code I read, and, my
own usage of that cool tool :) If I told something completely wrong here
above... Apologizes :]
Another idea about the implementation is to have non-void methods. For
example, you could have an assertFormPresent which returns a form object:
HtmlForm assertFormPresent(String formIdorName)
And further in your test, you could call an assert method on the HtmlForm
object. Let's say:
HtmlForm form = assertFormPresent("formid");
form.assertTextFieldPresent("textFieldIdorName");
Maybe the final code will be more readable... But I guess this requires a
very big refactoring of the existing code... But leave it for now :)
I hope I answered your questions. Probably some other users have ideas to
give about that topic :o)
Cheers,
Fred.
-----Original Message-----
From: Julien HENRY [mailto:[EMAIL PROTECTED]
Sent: Fri 7/7/2006 6:34 PM
To: Usage problems for jWebUnit
Cc: Frédéric Burlet
Subject: Re : [Jwebunit-users] Ideas
Hi Fred,
Thanks for your interest in jWebUnit evolution. Some of your request need a
bit of reflection. Could you please fill a feature request for
assertLabeled** methods.
Concerning assertHiddenElementWithNamePresent, I think
assertHiddenFieldPresent is a better name. You can fill another feature
request for it.
The main question I have concerning your feature requests is the following:
should we try to wrap as many XPath assertion as possible, or simply ask
jWebUnit users to use assertElementPresentByXPath in their test cases?
++
Julien
----- Message d'origine ----
De : Fred <[EMAIL PROTECTED]>
À : [email protected]
Envoyé le : Vendredi, 7 Juillet 2006, 4h17mn 59s
Objet : [Jwebunit-users] Ideas
Hi,
When I was writing tests I noticed that it could be usefull to add the
following methods to complete the set of basic ones:
assertLabeledTextFieldPresent(String textFieldId, String textFieldName,
String
labelContent)
assertLabeledCheckBoxPresent(String checkBoxId, String checkBoxName, String
labelContent)
assertLabeledSelectBoxPresent(String selectId, String selectName, String
labelContent)
assertLabeledTextAreaPresent(String textAreaId, String textAreaName, String
labelContent)
assertLabeledRadioButtonPresent(String radioId, String radioGroup, String
radioOption, String labelContent)
assertHiddenElementWithNamePresent(String hiddenName)
My first implementation was the following for example for the first one:
assertElementPresentByXPath("//[EMAIL PROTECTED]"" + labelForName + "\"
and .=\"" + labelContent + "\"]");
assertElementPresentByXPath("//[EMAIL PROTECTED]"text\" and @name=\"" +
textFieldId + "\" and @id=\"" + textFieldName + "\"]");
This clearly defines that we have a label with a for attribute which refers
to
a text field with the given id.
This allows me to detect some errors in the html generated by my jsp's :o)
Yes, indeed, I said "first implementation" because another idea came up while
writing this mail :o)
The assertLabeledTextFieldPresent could have an extra parameter which is the
form id or form name. This would imply that we check that a specific form has
a specific field...
My 1¢ contribution :o)
Regards,
Fred.
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-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-users
*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.
De : Frédéric Burlet <[EMAIL PROTECTED]>
À : Julien HENRY <[EMAIL PROTECTED]>; Usage problems for jWebUnit <[email protected]>
Envoyé le : Samedi, 8 Juillet 2006, 12h41mn 08s
Objet : RE: Re : [Jwebunit-users] Ideas
Hi Julien,
I will file a feature request for my suggestions... later after the week-end
:)
Now, about my implementation of assertLabeled**, I was using
assertElementPresentByXPath because that's the only way I found to write
these implementations based on jWebUnit.
If you want to include these methods in the set of basic ones, I would
suggest you to implement these methods based on the core plugin library. I
mean, in the jWebUnit-htmlunit-plugin, the implementation should be based on
htmlunit or another way around if not possible. Beside, you should let the
assertElementPresentByXPath available to users for the specific/weird cases.
In fact, I don't know how htmlunit is working... and I'm only guessing how
jWebUnit is working based on the documentation and the code I read, and, my
own usage of that cool tool :) If I told something completely wrong here
above... Apologizes :]
Another idea about the implementation is to have non-void methods. For
example, you could have an assertFormPresent which returns a form object:
HtmlForm assertFormPresent(String formIdorName)
And further in your test, you could call an assert method on the HtmlForm
object. Let's say:
HtmlForm form = assertFormPresent("formid");
form.assertTextFieldPresent("textFieldIdorName");
Maybe the final code will be more readable... But I guess this requires a
very big refactoring of the existing code... But leave it for now :)
I hope I answered your questions. Probably some other users have ideas to
give about that topic :o)
Cheers,
Fred.
-----Original Message-----
From: Julien HENRY [mailto:[EMAIL PROTECTED]
Sent: Fri 7/7/2006 6:34 PM
To: Usage problems for jWebUnit
Cc: Frédéric Burlet
Subject: Re : [Jwebunit-users] Ideas
Hi Fred,
Thanks for your interest in jWebUnit evolution. Some of your request need a
bit of reflection. Could you please fill a feature request for
assertLabeled** methods.
Concerning assertHiddenElementWithNamePresent, I think
assertHiddenFieldPresent is a better name. You can fill another feature
request for it.
The main question I have concerning your feature requests is the following:
should we try to wrap as many XPath assertion as possible, or simply ask
jWebUnit users to use assertElementPresentByXPath in their test cases?
++
Julien
----- Message d'origine ----
De : Fred <[EMAIL PROTECTED]>
À : [email protected]
Envoyé le : Vendredi, 7 Juillet 2006, 4h17mn 59s
Objet : [Jwebunit-users] Ideas
Hi,
When I was writing tests I noticed that it could be usefull to add the
following methods to complete the set of basic ones:
assertLabeledTextFieldPresent(String textFieldId, String textFieldName,
String
labelContent)
assertLabeledCheckBoxPresent(String checkBoxId, String checkBoxName, String
labelContent)
assertLabeledSelectBoxPresent(String selectId, String selectName, String
labelContent)
assertLabeledTextAreaPresent(String textAreaId, String textAreaName, String
labelContent)
assertLabeledRadioButtonPresent(String radioId, String radioGroup, String
radioOption, String labelContent)
assertHiddenElementWithNamePresent(String hiddenName)
My first implementation was the following for example for the first one:
assertElementPresentByXPath("//[EMAIL PROTECTED]"" + labelForName + "\"
and .=\"" + labelContent + "\"]");
assertElementPresentByXPath("//[EMAIL PROTECTED]"text\" and @name=\"" +
textFieldId + "\" and @id=\"" + textFieldName + "\"]");
This clearly defines that we have a label with a for attribute which refers
to
a text field with the given id.
This allows me to detect some errors in the html generated by my jsp's :o)
Yes, indeed, I said "first implementation" because another idea came up while
writing this mail :o)
The assertLabeledTextFieldPresent could have an extra parameter which is the
form id or form name. This would imply that we check that a specific form has
a specific field...
My 1¢ contribution :o)
Regards,
Fred.
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-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-users
*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.
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-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jwebunit-users
