-----Original Message-----
From: Matt Raible [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 01, 2005 6:22 PM
To: [email protected]
Subject: Re: [Jwebunit-users] Asserting option selected in form
This turned out to be caused by SiteMesh - which is quite
strange since
I have an app it works fine in (with the same SiteMesh
version) and it
doesn't work in this particular one.
I fixed it by subclassing the SiteMesh PageFilter with the following:
public class SitemeshFilter extends PageFilter {
public void doFilter(ServletRequest req, ServletResponse res,
FilterChain chain)
throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
String userAgent = request.getHeader("user-agent");
// prompt for login, except when jWebUnit is used
if (userAgent == null || !userAgent.startsWith("httpunit")) {
super.doFilter(req, res, chain);
return;
}
chain.doFilter(req, res);
}
}
Matt
On Feb 22, 2005, at 12:59 PM, Matt Raible wrote:
On Feb 17, 2005, at 2:17 PM, Nick Neuberger wrote:
Two things:
1) Put a breakpoint in HttpUnitDialog.getSelectedOption(String
selectName)
Iterate over each value and inspect the values.
I'd rather not download the source to httpunit, but I
suppose I will
if I have to.
2) You may have a CR LF problem between the begin and end tag of
</option>
I simplified the page I'm testing and just hard-coded the
drop-down as
follows:
<select name="me" id="me>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
This still fails on the setOption() call:
public void testAddUser() {
beginAt("/editUser.html");
assertTitleEqualsKey("userForm.title");
setWorkingForm("userForm");
setFormElement("firstName", "Spring");
setFormElement("lastName", "User");
selectOption("me", "1");
submit("save");
assertTitleEqualsKey("userList.title");
}
ERROR:
[junit] ------------- Standard Error -----------------
[junit] Rhino classes (js.jar) not found - Javascript disabled
[junit] ------------- ---------------- ---------------
[junit] Testcase:
testAddUser(org.appfuse.web.UserWebTest): Caused
an ERROR
[junit] Unable to find option 1 for me
[junit] java.lang.RuntimeException: Unable to find
option 1 for me
[junit] at
net.sourceforge.jwebunit.HttpUnitDialog.getValueForOption(Http
UnitDialo
g.java:863)
[junit] at
net.sourceforge.jwebunit.HttpUnitDialog.selectOption(HttpUnitD
ialog.jav
a:875)
[junit] at
net.sourceforge.jwebunit.WebTester.selectOption(WebTester.java:847)
[junit] at
net.sourceforge.jwebunit.WebTestCase.selectOption(WebTestCase.java:
341)
[junit] at
org.appfuse.web.UserWebTest.testAddUser(UserWebTest.java:33)
My guess is there's some JAR in my classpath that's causing
a conflict
or maybe it's the XHTML transitional doctype I have set. The last
thing I can think of is that maybe SiteMesh is getting in
the way. I
don't think so though - the setFormElement works fine.
Matt
This CFLF problem with not allow two object to equal.
3) Are you using an object based html rendering engine....
ie. some
have a
Pretty Print option.
4) Some browsers when using "view-source" will give a
pretty view of
the
content and thus "hiding" a CFLF.
Good Luck!!! HTH...
Nick
-----Original Message-----
From: Matt Raible [mailto:[EMAIL PROTECTED]
Sent: Thursday, February 17, 2005 1:03 PM
To: [email protected]
Subject: [Jwebunit-users] Asserting option selected in form
I'm using the following code to assert the proper option
is selected
in
a name="companyName" <select>:
assertFormElementEquals("startDate",
formatter.format(startDate));
assertFormElementEquals("endDate",
formatter.format(endDate));
assertFormElementPresent("companyName");
assertOptionEquals("companyName", "NSPP");
However, I'm getting:
[junit] expected:<NSPP> but was:<null>
[junit] junit.framework.ComparisonFailure: expected:<NSPP> but
was:<null>
[junit] at
net.sourceforge.jwebunit.WebTester.assertOptionEquals(WebTester.java:
538)
[junit] at
net.sourceforge.jwebunit.WebTestCase.assertOptionEquals(WebTes
tCase.ja
va
:212)
If I do a view-source of this form in my browser - it all
looks right:
<select name="companyName" id="companyName"><option
value="">All</option>
<option value="NSPP"
selected="selected">NSPP</option></select>
Thanks,
Matt
-------------------------------------------------------
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-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-users
- - - - - -
This e-mail message is intended only for the use of the
individual or
entity
identified in the alias address of this message and may contain
confidential
and privileged information. Any unauthorized review, use,
disclosure
or
distribution of this e-mail message is strictly
prohibited. If you
have
received this e-mail message in error, please notify the sender
immediately
by reply e-mail and delete this message from your system.
Thank you.
-------------------------------------------------------
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-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-users
-------------------------------------------------------
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-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-users
-------------------------------------------------------
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-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-users