Skip to content

Null body #271

Description

@cdalexndr

I need to parse a html string.
Migrated from htmlunit 2.36.0 to 2.45.0 and now body is null:

String html = "<!DOCTYPE html><html><head></head><body></body></html>";
WebClient client = new WebClient();
client.getOptions().setCssEnabled( false );
client.getOptions().setJavaScriptEnabled( false );
StringWebResponse response = new StringWebResponse( html, new URL( "http://dummy.com" ) );
HtmlPage page = (HtmlPage) client.getPageCreator().createPage( response, client.getCurrentWindow() );
client.getPageCreator().getHtmlParser().parse( response, page, false );
assertNotNull( page.getBody() );

Htmlunit 2.36.0 code is similar but parsing differs:

HtmlPage page = HTMLParser.parseHtml( response, client.getCurrentWindow() );

A standard way of parsing html string, without relying on internal library code that may change, would be helpful.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions