title: HtmlUnit issue with login popup
body: <p>Been reading this forum for a while but just signed up, this is my first post, so kudos for the great job done here.</p>
  
  <p>I am writing a program in Java with the purpose of using HtmlUnit to connect to one of the magazines I am a subscriber at, login and search for articles that interest me. Once I get that working it will send me an email but that's not relevant to my question.</p>
  
  <p>I can't get the login to work: </p>
  
  <ul>
  <li>I read the page</li>
  <li>Find the login button and click it</li>
  <li>Capture the result in a new page, extract the form and supply username/password and finally</li>
  <li>click on login button</li>
  </ul>
  
  <p>If you click on login, a popup comes up. But I can't seem to be able to capture the popup.</p>
  
  <p>This is my code:</p>
  
  <pre><code>public void authenticate() throws MalformedURLException, IOException
  {
  
      LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog");      
      java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(Level.OFF); 
      java.util.logging.Logger.getLogger("org.apache.commons.httpclient").setLevel(Level.OFF);
  
      WebClient webClient = new WebClient(BrowserVersion.INTERNET_EXPLORER_9);
      webClient.getOptions().setJavaScriptEnabled(true);
      webClient.getCookieManager().setCookiesEnabled(true);
      webClient.getOptions().setThrowExceptionOnScriptError(false);
      webClient.getOptions().setPopupBlockerEnabled(false);
  
      webClient.addWebWindowListener(new WebWindowListener()
      {
  
            public void webWindowOpened(WebWindowEvent event)
  
            {
                System.out.println("a NEW window opened: " + event.getNewPage());
                windows.add(event.getWebWindow()); 
  
            }
  
          @Override
          public void webWindowClosed(WebWindowEvent event) {
              System.out.println("a window is CLOSED: " + event.getOldPage()); 
              // TODO Auto-generated method stub
  
          }
  
          @Override
          public void webWindowContentChanged(WebWindowEvent event) {}
  
      });
  
      // Get the first page
      HtmlPage page1 = webClient.getPage("**");
      HtmlDivision div = (HtmlDivision) page1.getElementById("topContainer"); 
  
      HtmlAnchor anchor = (HtmlAnchor) div.getElementById("loginBtn1");       
      HtmlPage logPage = (HtmlPage) anchor.click();
      System.out.println("logPage is: "+logPage);
  
      if ( windows.size() &gt; 0)
      {
          System.out.println("YIOUHOUU");
              HtmlPage popupPage = getPopupPage();
              System.out.println(popupPage.getTitleText());
      } 
  
      HtmlForm form = logPage.getFormByName("loginForm");
      System.out.println("Form: "+ form);
  
      HtmlTextInput username = form.getInputByName("username");
      HtmlPasswordInput password = form.getInputByName("password");
      HtmlCheckBoxInput rememberPassword = form.getInputByName("remember");
      HtmlCheckBoxInput acceptTerms = logPage.getElementByName("acceptTerms");
      HtmlAnchor button = form.getElementById("loginButton");
  
      username.setValueAttribute("USER");
      password.setValueAttribute("RANDOM_PASS");
      rememberPassword.setChecked(true);
      acceptTerms.setChecked(true);
  
      System.out.println(form.toString());
  
      HtmlPage page2 = button.click();
      System.out.println(page2.asText());
      webClient.closeAllWindows();
  }
  </code></pre>
  
  <p>I get the login page, get the form and supply the fields. All that is done, but when on the second page and click login nothing happens.</p>
  
  <p>Even if you submit fields and click SUbmit nothing happens. I am looking at source of html page but can't figure out why, is it ajax or sth else in the background?</p>
  
  <p>Thanks in advance for any help</p>