Question : Pop up windows in HtmlUnit

When I click on a button on a webpage a popup window generated by javascript opens.
I got a handler to click the OK button on the popup window. That is meant to open another page.
How do I get hold of the code of this new page, so I can click buttons  on it?

Thank you,

Ana

Answer : Pop up windows in HtmlUnit

final WebClient webClient = new WebClient(BrowserVersion.INTERNET_EXPLORER_8);
DefaultCredentialsProvider userCredentials = new DefaultCredentialsProvider();
userCredentials.addNTLMCredentials("xxxxx", "xxxxx", null, -1, "xxxxx", "xxxx");
webClient.setCredentialsProvider(userCredentials);

//to make it possible clicking on the OK button generated by js
ConfirmHandler okHandler = new ConfirmHandler(){
       public boolean handleConfirm(Page page, String message) {
      return true;
                      }
        };
webClient.setConfirmHandler(okHandler);

WebClient.addWebWindowListener(new WebWindowAdapter() {
   public void webWindowOpened(WebWindowEvent event) {
      System.out.println("Opened");
   }
});
final HtmlPage page = webClient.getPage("http://cbrint78/dms_test_new_code/ProjectsDisc.aspx?id=1726");
...

Random Solutions  
 
programming4us programming4us