HtmlUnit - handling client side redirect



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.

.



Relevant Pages

  • Re: HtmlUnit
    ... in my R&D I came across HtmlUnit ... Samie, Pamie, Watir, JSUnit, Selenium, and HttpUnit are its competition, ... HtmlUnit, IIRC, only reads HTML. ... It mocks a web browser, ...
    (comp.software.testing)
  • Re: HtmlUnit
    ... > Recently I have been working with Junit and HttpUnit. ... limited and needed to drop down to using rhino and httpunit. ... Someone else at my site suggested htmlunit. ... darrell dot grainger at utoronto dot ca ...
    (comp.software.testing)
  • HtmlUnit (or HttpUnit) - Javascript and iFrames
    ... I am wondering if anyone has experience working with js and iframes in ... httpunit or htmlunit? ... The application I am working with has multiple iframes that get loaded ... I am wondering how difficult it is to do simple js calls from httpUnit ...
    (comp.software.testing)
  • Re: Unittesting for web applications
    ... Httpunit and Htmlunit, ... of variants. ... > unittests for web applications? ...
    (comp.lang.python)