I was able to login to a website the first time but for later requests with different credentials, HTMLUnit is giving 200 instead of 302.
Any ideas why I'm not getting 302 for successive requests? I believe it's because the server is sending:
Expires: Sun, 12 Jul 2015 01:24:57 GMT[\r][\n]"
2015-07-11 11:25:01,968 DEBUG [org.apache.http.wire:63][pool-6-thread-2] - << "Cache-Control: public, max-age=36000[\r][\n]"
in response. How do I overcome this?
final WebClient webClient = new WebClient();
final HtmlPage page1 = webClient.getPage(Url);
final HtmlForm form = page1.getFormByName("form_name");
final HtmlSubmitInput button = form.getInputByValue("Sign In");
final HtmlTextInput user = form.getInputByName("username");
user.setValueAttribute("admin");
final HtmlPasswordInput pass = form.getInputByName("password");
pass.setValueAttribute("admin");
final HtmlPage page2 = button.click();
HtmlAnchor anchor = page2.getAnchorByText("logout");
anchor.click();
webClient.getCache().clear();
webClient.getCookieManager().clearCookies();
webClient.closeAllWindows();
I'm using this code from Liferay Tomcat.