I'm also a new user, so please don't trust any of my assertions.  Whenever I
used beginAt(..) after logging in, my authentication also seemed to be
lost.  I tried checking the cookies, but didn't have much luck there (the
list getTestContext().getCookies() had 0 entries).  My solution was to use
beginAt once, and navigate by clicking links from thereon.

I created a superclass, BaseTestCase, whose responsibility is to log-in.
Every one of my tests that needs authentication extends it.  Below is a
simple example, but I can also send you my actual code.

public class BaseTestCase extends WebTestCase {

   public BaseTestCase(String name) { super(name); }
   public void setUp() throws Exception {
       super.setUp();

       beginAt("/wherever...");
       /*** login instructions here ***/
   }
}

public class MyTest extends BaseTestCase {
   public MyTest(String name) { super(name); }
   public void setUp() throws Exception {
       super.setUp ();
   }

   public testLink1() {
       clickLinkWithText("link1");
   }

}


One drawback is that every test that is run will go through the login
process (slow).
To find where I am for a WebTestCase, I check my setUp() method to see which
link I clicked to get wherever I am.  This gets confusing, but it works...

Does this help?  Is there a better way?

-- Dan Kigelman


On 7/11/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

 Is there documentation for jwebunit which explains how to use jwebunit
with an application which requires you to login/authenticate before getting
to a main page?

I am trying to automate testing of an application which requires an
authenticated user.  I am able to get to the login, send username and
password and get the correct <title> of the main page.  Once at the main
page I check the following:

assertTitleEquals(
"mainpage name");

which works fine.
I then select a link to the "next" page but from that point forward
nothing seems to work.

I reset "beginAt" to reflect the "next" page that I want to test once I
have verified that the title is correct in the original page.  I am not able
to assertTitleEquals on the "next" page.

I have checked "View Source" in IE to verify that the title I am checking
for is correct.

Thanks in advance of any pointers.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
JWebUnit-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-users


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
JWebUnit-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-users

Reply via email to