HtmlUnit - handling client side redirect
- From: "kalensr" <kalen.howell@xxxxxxxxxxxxx>
- Date: 2 Nov 2005 13:16:17 -0800
Greetings:
Below I have posted some examples of both successfully handling client
side redirect using HTTPUnit to log into an appliction, as well as my
attempt to log into the same application using HTMLUnit.
If anyone has any suggestions for me I would greatly appreciate the
help.
Thanks
___________________
Client side redirect indicated by:
<noscript><meta http-equiv="Refresh"
content="0;URL=NoJS.jsp"></noscript>
Handled in HttpUnit like such:
WebResponse response = form.submit();
WebRequest refreshReq;
refreshReq = response.getRefreshRequest();
System.out.println("refresh request: " + refreshReq.getURL());
// get new response using refreshReq URL
response = wc.getResponse(refreshReq.getURL().toString());
assertNotNull("Response from Refresh Request: ", response);
Attempting to perform same actions in HtmlUnit:
final WebClient webClient = new
WebClient(BrowserVersion.INTERNET_EXPLORER_6_0);
webClient.setRefreshHandler(new ImmediateRefreshHandler());
webClient.setRedirectEnabled(true);
webClient.setThrowExceptionOnFailingStatusCode(false);
final URL url = new URL(envUrl);
final HtmlPage page = (HtmlPage)webClient.getPage(url);
final HtmlForm form = page.getFormByName("main");
form.setAttributeValue("webId", id);
form.setAttributeValue("password", pwd);
Page newPage = form.submit();
assertNotNull("new page/", newPage);
newPage.initialize();
WebResponse response = newPage.getWebResponse();
RESULT
I am not able to log in using HtmlUnit but I am successful using
HttpUnit.
.
- Follow-Ups:
- Re: HtmlUnit - handling client side redirect
- From: Phlip
- Re: HtmlUnit - handling client side redirect
- Prev by Date: Re: high severity-low priority
- Next by Date: Re: HtmlUnit - handling client side redirect
- Previous by thread: Better Software Magazine feature article - Brushing up on Test Effectiveness
- Next by thread: Re: HtmlUnit - handling client side redirect
- Index(es):
Relevant Pages
|