admin管理员组

文章数量:1289383

If you inspect / using Chrome on Windows 11, you will see that the page has two forms.

But if you run the following code on Apache Netbeans 25 using JDK 24 and HtmlUnit 4.7.0, you will see that no forms are loaded:

package pima;

import .htmlunit.*;
import .htmlunit.html.*;

public class Pima {
    public static void main(String[] args) {
        try (final WebClient webClient = new WebClient(BrowserVersion.FIREFOX)) {
  java.util.logging.Logger.getLogger(".htmlunit").setLevel(java.util.logging.Level.OFF);
            webClient.getOptions().setCssEnabled(false);
            webClient.getOptions().setThrowExceptionOnScriptError(false);
            webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
            HtmlPage page = webClient.getPage("/");
            webClient.waitForBackgroundJavaScriptStartingBefore(1_000_000);
            page = (HtmlPage) page.getEnclosingWindow().getEnclosedPage();
            System.out.println("page.asXml() = " + page.asXml());
        }
        catch (Exception e) {
            System.out.println("Exception:  " + e.toString());
        }    
    }    
}

How do I need to change the above code to load the two forms?

Any suggestions on what I might try will be appreciated.

本文标签: javaHtmlUnit 470 Not Loading FormsStack Overflow