Skip to content

Migrate from net.sourceforge.htmlunit to org.htmlunit#16

Open
akshayrai10 wants to merge 2 commits into
masterfrom
issue/migrate-to-org-htmlunit
Open

Migrate from net.sourceforge.htmlunit to org.htmlunit#16
akshayrai10 wants to merge 2 commits into
masterfrom
issue/migrate-to-org-htmlunit

Conversation

@akshayrai10

@akshayrai10 akshayrai10 commented Apr 7, 2026

Copy link
Copy Markdown

Summary

  • Upgrades HtmlUnit from the abandoned net.sourceforge.htmlunit coordinates to the actively maintained org.htmlunit:htmlunit:3.9.0, resolving two critical CVEs
  • Updates the Selenium HtmlUnit Driver in jwebunit-webdriver-plugin from selenium-htmlunit-driver:2.52.0 to htmlunit3-driver:4.13.0, which is the only Selenium 4 driver that correctly depends on org.htmlunit:htmlunit:3.x and fully removes net.sourceforge.htmlunit from the classpath
  • Fixes all API breaking changes introduced in HtmlUnit 3.x

Key API Breaking Changes Addressed

  • Package rename: all com.gargoylesoftware.htmlunit.* → org.htmlunit.*
  • DefaultCredentialsProvider.addCredentials(): password changed from String to char[]; addNTLMCredentials() removed, replaced with generic addCredentials() (NTLM negotiation is handled internally by HtmlUnit)
  • HC5 shading: HtmlUnit 3.x bundles Apache HttpClient 5 internally, HC5 types are not importable by downstream consumers. Cookie.toHttpClient() replaced with direct org.htmlunit.util.Cookie API calls
  • HtmlElement.asText() renamed to asNormalizedText()
  • HtmlInput value semantics: in HtmlUnit 3.x, setValueAttribute() mutates the HTML attribute (the form-reset default) rather than the live DOM value. Replaced with setValue() at all call sites that intend to set user-visible field values; getValueAttribute() → getValue() for reading live DOM values
  • CapabilityType.SUPPORTS_JAVASCRIPT: removed in Selenium 4 with no named constant replacement (W3C WebDriver spec does not include javascriptEnabled). Replaced with string literal "javascriptEnabled"
  • XPath engine: HtmlUnit 3.x uses a strict XPath 1.0 evaluator (Apache Xalan). lower-case() (XPath 2.0) replaced with translate() equivalent in WebTester.java

To de‑risk the HtmlUnit 2.x → 3.x upgrade and Selenium driver changes, a dedicated suite of migration‑specific tests was added under jwebunit-htmlunit-plugin. These tests explicitly cover each behaviour change introduced by the new stack

  • HtmlUnitCookieMappingTest - Verifies the rewritten getCookies() implementation after dropping Cookie.toHttpClient() (HC4) in favour of direct org.htmlunit.util.Cookie access.
  • HtmlUnitValueSemanticsTest - Guards the new value semantics after switching from setValueAttribute() / getValueAttribute() to setValue() / getValue() on HtmlInput and in HtmlUnitElementImpl:
  • HtmlUnitCheckboxCaseInsensitiveTest - Validates the XPath fix from the unsupported XPath 2.0 lower-case() function to the XPath 1.0 translate() equivalent in WebTester:
  • HtmlUnitTestingEngineImplTest additions - Extends existing tests to cover new migration‑critical behaviour:

Rovo Dev code review: Rovo Dev couldn't review this pull request
Upgrade to Rovo Dev Standard to continue using code review.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant