Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

com.gargoylesoftware.htmlunit.ScriptException: Error: Bootstrap's JavaScript requires jQuery version 1.9.1 or higher #127

Closed
AbdenourAchab opened this issue Feb 4, 2020 · 8 comments

Comments

@AbdenourAchab
Copy link

I am trying to browse http://taxtest.navajocountyaz.gov/Pages/WebForm1.aspx?p=1&apn=10301003B using Java code and the latest release of HTMLUnit (version 2.37.0, which I downloaded from https://jar-download.com/artifact-search/htmlunit along with all its dependencies).

final WebClient webClient = new WebClient();
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.setRefreshHandler(new RefreshHandler() {
	public void handleRefresh(Page page, URL url, int arg) throws IOException {
	    System.out.println("handleRefresh");
	}
});
HtmlPage page = (HtmlPage) webClient.getPage("http://taxtest.navajocountyaz.gov/Pages/WebForm1.aspx?p=1&apn=10301003B");

The last line of code throws the following exception:
com.gargoylesoftware.htmlunit.ScriptException: Error: Bootstrap's JavaScript requires jQuery version 1.9.1 or higher (http://taxtest.navajocountyaz.gov/js/bootstrap.js#15)

I thought the problem was with my code. So, I sought help at https://stackoverflow.com/questions/60030255/com-gargoylesoftware-htmlunit-scriptexception-error-bootstraps-javascript-req and, according to RBRi, it "Looks like a problem inside HtmlUnit itself."

Please fix the problem in an upcoming release of HTMLUnit. In the meantime, I would appreciate a workaround for my code, including, if possible, which older release of HTMLUnit I need to revert back to avoid the problem.

Thank you.

@php-coder
Copy link
Contributor

php-coder commented Feb 5, 2020

I don't think that this is htmlunit issue: I opened this page in Firefox and it shows the same error. The page loads jquery 1.7.1 while bootstrap requires >= 1.9.1 and that's why it complains.

@AbdenourAchab
Copy link
Author

Firefox may well show the same error. But, when I open the http://taxtest.navajocountyaz.gov/Pages/WebForm1.aspx?p=1&apn=10301003B page with Firefox, I am able to see the dollar figures under "Cash Value". With HTMLUnit, I am not able to extract such values. So, for this page, HTMLUnit is not performing as well as Firefox. I would like for there to be a way in HTMLUnit to extract those dollar figures from the web page, regardless of the existence of the jQuery error.

@rbri
Copy link
Member

rbri commented Feb 10, 2020

Have done a quick test

    String uri = "http://taxtest.navajocountyaz.gov/Pages/WebForm1.aspx?p=1&apn=10301003B";

    try (final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_68)) {
        webClient.getOptions().setThrowExceptionOnScriptError(false);

        HtmlPage page = webClient.getPage(uri);

        System.out.println(page.asText());
    }

Looks like everything is there. Can you please check and provide more details about the missing content.

@AbdenourAchab
Copy link
Author

AbdenourAchab commented Feb 10, 2020

I just tried your code, and I am getting the same exception at the

    HtmlPage page = webClient.getPage(uri);

line of code.

Maybe the problem is with the HTMLUnit+Dependencies that I downloaded from https://jar-download.com/artifact-search/htmlunit . Maybe the maintainer of jar-download.com got some version(s) of the dependencies wrong.

Could you download the 2.37.0 version of HTMLUnit+Dependencies from https://jar-download.com/artifact-search/htmlunit , try your code with it, and see whether it still works ?

I know I can also download HTMLUnit from the official site. I used to do that. But then it used to take me forever to track down all the dependencies and the dependencies of the dependencies. So, I would appreciate if you could first try the above hypothesis to see whether or not the problem is with the jar-download.com site. Then, if it is, I will download HTMLUnit from its official site.

@rbri
Copy link
Member

rbri commented Feb 11, 2020

You are sure the code throws the exception? I guess the exception is only in the logs but the code produces some output here.

Regarding the download - htmlunit-2.37.0-bin.zip from the official download location contains all you need (including all dependent libs). Do you miss something in this package?

@rbri
Copy link
Member

rbri commented Feb 11, 2020

BTW if you like to ignore the js errors you can use

webClient.setJavaScriptErrorListener(new SilentJavaScriptErrorListener());

@AbdenourAchab
Copy link
Author

The following import statement:

    import com.gargoylesoftware.htmlunit.javascript.*;

and adding the following code

    webClient.setJavaScriptErrorListener(new SilentJavaScriptErrorListener());

did fix the problem.

Thank you very much rbri for your help. I am going to close this issue.

@rbri
Copy link
Member

rbri commented Feb 12, 2020

Thanks for the feedback.

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

No branches or pull requests

3 participants