-
1. Re: How to test link with target _blank is opened?
ssilvert Feb 15, 2010 9:32 AM (in response to jadtn)Hi Adrien,
Using the HtmlUnit API with JSFUnit has a section on working with multiple windows. That will take care of the client side.
server.getCurrentViewID() should work as long as the new window is using the same HttpSession. I took a look at the JSFUnit test suite and I don't have any tests for the server side in that situation. Please let me know what you find.
Regards,
Stan
-
2. Re: How to test link with target _blank is opened?
jadtn Apr 5, 2010 12:50 PM (in response to jadtn)A sample if someone need
//link on my home page
<a id="lp" href="/pages/pub/lostpwd.jsf" target="_blank">Lost password</a>
WebClient webClient = jsfSession.getWebClient();
HtmlPage firstPage = webClient.getPage("http://localhost/");
//id of the link
HtmlAnchor anchor = firstPage.getHtmlElementById("lp");
Page secondPage = anchor.click();
//id of button on second page "/pages/pub/lostpwd.jsf
assertTrue(secondPage.getWebResponse().getContentAsString().contains("lostpwd:b_getpwd"));