jeudi 6 octobre 2016

Open a web browser page after a POST request using Htmlunit library

I'm testing my website and what I do is moving inside of it using Htmlunit library and Java. Like this for example:

WebClient webClient = new WebClient(BrowserVersion.FIREFOX_45);

HtmlPage page1 = webClient.getPage(mypage);

// sent using POST  
HtmlForm form = page1.getForms().get(0);

HtmlSubmitInput button = form.getInputByName("myButton");
HtmlPage page2 = button.click();

// I want to open page2 on a web browser and continue there using a function like
// continueOnBrowser(page2);

I filled a form programmatically using Htmlunit then I sent the form which uses a POST method. But I'd want to see the content of the response inside a web browser page. The fact is that if I use the URL to see the response it doesn't work since it's the response to a POST method.

It seems like it's the wrong approach to me, it's obvious that if you do anything programmatically you could not expect to open the browser and continue there... I can't figure out what could solve my problem.

Do you have any suggestions?




Aucun commentaire:

Enregistrer un commentaire