Hello:
I am pretty new to JWebUnit and I am trying to use it
to test a website I am building. It is important for
my website for a cookie to remain across requests to
maintain a session on the server. I am having no luck
in getting jWebUnit to remember the cookie on my
second request, nor can I find the answer that I am
looking for on the net.
Basically I assert that the cookie is present after a
beginAt() and it is there and I can write out the
value, then I clickLinkWithText() and a second assert
of cookie being present fails. So, what am I missing
or doing wrong? More code is below in case more
details helps.
Here is a code snippet of what I am doing.
<-------Begin Code----------->
public static final String MY_INSTANCE =
"http://myserver:myport";
public static final String BASE_URL =
"/myurl/mypage.jhtml?param1=paramVal¶m2=paramVal";
public TestMyTest(String pName) {
super(pName);
HttpUnitOptions.setExceptionsThrownOnScriptError(
false );
HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
CookieProperties.setDomainMatchingStrict(false);
CookieProperties.setPathMatchingStrict(false);
ClientProperties props =
ClientProperties.getDefaultProperties();
System.out.println("Cookies Accepted?" +
props.isAcceptCookies());
getTestContext().setBaseUrl(MY_INSTANCE);
}
public void testMyPath() throws Exception {
beginAt(BASE_URL);
assertTitleEquals("Page1");
this.assertCookiePresent("mycookie");
System.out.println("CookieValue: " +
this.getTestContext().getWebClient().getCookieValue("JSESSIONID"));
assertLinkPresentWithText("Some Link");
clickLinkWithText("Some Link");
assertTitleEquals("Page2");
this.assertCookiePresent("mycookie");
submit(submitButtonName);
assertTitleEquals("nextPage");
....
}
<-------End Code----------->
The result that I get back is:
Cookies Accepted?true
CookieValue: cookieVal
Then an exception is thrown on the second assert that
the cookie is NOT present. So I am losing the cookie
somehow in the second request when I click on the
link.
I would really like to use this cool library to code
some tests of the site, but without cookies I am not
able to do anything interesting.
Any help is appreciated.
-Don
__________________________________
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail
-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 13. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Jwebunit-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jwebunit-users