Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7017943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:58:46+00:00 2026-05-27T22:58:46+00:00

HtmlUnit throws exception and crash my test when I’m loading the page caps =

  • 0

HtmlUnit throws exception and crash my test when I’m loading the page

caps = Selenium::WebDriver::Remote::Capabilities.htmlunit(:javascript_enabled => true)
driver = Selenium::WebDriver.for(:remote, :desired_capabilities => caps)
driver.navigate.то url

ReferenceError: “x” is not defined.
(net.sourceforge.htmlunit.corejs.javascript.EcmaError)

No exception is thrown if I use a Firefox driver.

caps = Selenium::WebDriver::Remote::Capabilities.firefox

Or disable JavaScript for HtmlUnit driver

caps = Selenium::WebDriver::Remote::Capabilities.htmlunit(:javascript_enabled => false)

I am unable to change the code on the test page and fix the problem, so I need to either ignore it or in any way to use Firefox JavaScript Engine instead of the standard HtmlUnit JavaScript Engine.

Is it possible to solve my problem without changing the code of test page?

Update:
Tried Capybara + WebKit as an alternative to Selenium + HtmlUnit – works fine, without errors. But still I would like to solve the problem without changing the framework.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:58:47+00:00Added an answer on May 27, 2026 at 10:58 pm

    After looking at the source of the HtmlUnitDriver, it seems like there is no possibility to customize the behaviour you want to change. The easiest thing you could do to solve this is to patch and recompile the Selenium server (which might or might not be an option). You’d need to add this line:

    --- HtmlUnitDriver.java 2012-01-05 17:45:22.779579136 +0100
    +++ HtmlUnitDriver.java 2012-01-05 18:14:51.415106195 +0100
    @@ -255,6 +255,7 @@
         WebClient client = newWebClient(version);
         client.setHomePage(WebClient.URL_ABOUT_BLANK.toString());
         client.setThrowExceptionOnFailingStatusCode(false);
    +    client.setThrowExceptionOnScriptError(false);
         client.setPrintContentOnFailingStatusCode(false);
         client.setJavaScriptEnabled(enableJavascript);
         client.setRedirectEnabled(true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently using HtmlUnit and Selenium to drive it (WebDriver) within my production
I have a simple HTML page (ratings.html) that I'm trying to test using HtmlUnit.
htmlunit reports everything from css, to parsing errors on a page. how to silence
I'm trying to use HtmlUnit to test that my GWT website loads properly. Unfortunately,
I'm trying to patch HtmlUnit with the patches at the bottom of this page.
I have a page that comes back as an UnexpectedPage in HtmlUnit, the response
So I'm trying to load a page with HtmlUnit in Java and I am
I'm trying to learn how to use HTMLUnit in order to test some website's
Running the example source at http://code.google.com/p/selenium/wiki/GettingStarted It runs successfully, however Eclipse throws bunch of
I'm currently using HtmlUnit to attempt to grab an href out of a page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.