I am trying to access a URL (admin.do
) directly after logging into the application and the URL is a restricted page. However, when I run the scenario on browser, I am able to see the page getting redirected to access denied page. However, when I run the same with htmlunit, I see the following exception instead.
com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException: 403 Forbidden for https://localhost:27216/app/admin.do
at com.gargoylesoftware.htmlunit.WebClient.throwFailingHttpStatusCodeExceptionIfNecessary(WebClient.java:536)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:331)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:387)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:372)
Any idea how to achieve this? Here is my code.
HtmlPage resp = null;
WebClient webClient = getWebClient();
HtmlPage page = (HtmlPage) webClient.getPage(url);