Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

268
Views
Why is HtmlUnit latest version throwing JS error with d3 version 6 when rendered in headless mode?

I am trying to render the HTML containing d3(d3.v6.3.1.min.js) using HtmlUnit in headless mode. I am using the latest version of HtmlUnit . Getting some issue. Please find the below details.

How can I fix it?

Here is my code :

WebClient webClient = new WebClient(BrowserVersion.BEST_SUPPORTED);
//webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.getOptions().setJavaScriptEnabled(true);
File file = new File("Path of the html");
HtmlPage page = webClient.getPage(file.toURI().toURL().toString());
String js = "var data = "+jsonSeries+";\n";
js += "drawChart(data);";
webClient.waitForBackgroundJavaScript(10000);
page.executeJavaScript(js);
svgImage = page.asXml().substring(page.asXml().indexOf("<svg"),page.asXml().indexOf("</svg>")+6);

Here is the error log :

Caused by: net.sourceforge.htmlunit.corejs.javascript.EvaluatorException: syntax error (file: d3.v6.3.1.min.js#2)
    at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory$HtmlUnitErrorReporter.error(HtmlUnitContextFactory.java:436) ~[htmlunit-2.54.0.jar:2.54.0]
    at net.sourceforge.htmlunit.corejs.javascript.Parser.addError(Parser.java:251) ~[htmlunit-core-js-2.54.0.jar:?]
    at net.sourceforge.htmlunit.corejs.javascript.Parser.reportError(Parser.java:330) ~[htmlunit-core-js-2.54.0.jar:?]
    at net.sourceforge.htmlunit.corejs.javascript.Parser.reportError(Parser.java:321) ~[htmlunit-core-js-2.54.0.jar:?]
    at net.sourceforge.htmlunit.corejs.javascript.Parser.reportError(Parser.java:314) ~[htmlunit-core-js-2.54.0.jar:?]
    at net.sourceforge.htmlunit.corejs.javascript.Parser.primaryExpr(Parser.java:3114) ~[htmlunit-core-js-2.54.0.jar:?]
    at net.sourceforge.htmlunit.corejs.javascript.Parser.memberExpr(Parser.java:2665) ~[htmlunit-core-js-2.54.0.jar:?]
    at net.sourceforge.htmlunit.corejs.javascript.Parser.unaryExpr(Parser.java:2568) ~[htmlunit-core-js-2.54.0.jar:?]
    at net.sourceforge.htmlunit.corejs.javascript.Parser.expExpr(Parser.java:2488) ~[htmlunit-core-js-2.54.0.jar:?]
    at net.sourceforge.htmlunit.corejs.javascript.Parser.mulExpr(Parser.java:2471) ~[htmlunit-core-js-2.54.0.jar:?]
    at net.sourceforge.htmlunit.corejs.javascript.Parser.addExpr(Parser.java:2457) ~[htmlunit-core-js-2.54.0.jar:?]
    at net.sourceforge.htmlunit.corejs.javascript.Parser.shiftExpr(Parser.java:2440) ~[htmlunit-core-js-2.54.0.jar:?]
    at net.sourceforge.htmlunit.corejs.javascript.Parser.relExpr(Parser.java:2418) ~[htmlunit-core-js-2.54.0.jar:?]
    at net.sourceforge.htmlunit.corejs.javascript.Parser.eqExpr(Parser.java:2394) ~[htmlunit-core-js-2.54.0.jar:?]
    at net.sourceforge.htmlunit.corejs.javascript.Parser.bitAndExpr(Parser.java:2385) ~[htmlunit-core-js-2.54.0.jar:?]
    at net.sourceforge.htmlunit.corejs.javascript.Parser.bitXorExpr(Parser.java:2376) ~[htmlunit-core-js-2.54.0.jar:?]
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!