-
-
Notifications
You must be signed in to change notification settings - Fork 86
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
To ignore - Error during JavaScript execution #131
Comments
Yes there is...
Use the more customization sample from
https://github.com/SeleniumHQ/htmlunit-driver
and set
webClient.getOptions().setThrowExceptionOnScriptError(false);
RBRI
Am 9. Juni 2023 21:35:46 MESZ schrieb suntong ***@***.***>:
…Hope there is way to _enable_ javascript support but _ignore_ all its errors.
I'm getting `Error during JavaScript execution` on **googlesyndication**:
```
19:23:54.409 [pool-3-thread-1] ERROR org.htmlunit.javascript.DefaultJavaScriptErrorListener - Error during JavaScript execution
org.htmlunit.ScriptException: missing ) after formal parameters (https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4501446722471304#22)
at org.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:990) ~[htmlunit-3.3.0.jar:3.3.0]
at org.htmlunit.corejs.javascript.Context.call(Context.java:590) ~[htmlunit-core-js-3.3.0.jar:?]
at org.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:484) ~[htmlunit-core-js-3.3.0.jar:?]
at org.htmlunit.javascript.HtmlUnitContextFactory.callSecured(HtmlUnitContextFactory.java:348) ~[htmlunit-3.3.0.jar:3.3.0]
at org.htmlunit.javascript.JavaScriptEngine.compile(JavaScriptEngine.java:819) ~[htmlunit-3.3.0.jar:3.3.0]
at org.htmlunit.javascript.JavaScriptEngine.compile(JavaScriptEngine.java:785) ~[htmlunit-3.3.0.jar:3.3.0]
at org.htmlunit.javascript.JavaScriptEngine.compile(JavaScriptEngine.java:114) ~[htmlunit-3.3.0.jar:3.3.0]
at org.htmlunit.html.HtmlPage.loadJavaScriptFromUrl(HtmlPage.java:1151) ~[htmlunit-3.3.0.jar:3.3.0]
at org.htmlunit.html.HtmlPage.loadExternalJavaScriptFile(HtmlPage.java:1023) ~[htmlunit-3.3.0.jar:3.3.0]
at org.htmlunit.html.ScriptElementSupport.executeScriptIfNeeded(ScriptElementSupport.java:194) ~[htmlunit-3.3.0.jar:3.3.0]
at org.htmlunit.html.ScriptElementSupport$1.execute(ScriptElementSupport.java:118) ~[htmlunit-3.3.0.jar:3.3.0]
at org.htmlunit.html.HtmlPage.initialize(HtmlPage.java:341) ~[htmlunit-3.3.0.jar:3.3.0]
at org.htmlunit.WebClient.loadWebResponseInto(WebClient.java:685) ~[htmlunit-3.3.0.jar:3.3.0]
at org.htmlunit.WebClient.loadWebResponseInto(WebClient.java:567) ~[htmlunit-3.3.0.jar:3.3.0]
at org.htmlunit.WebClient.getPage(WebClient.java:485) ~[htmlunit-3.3.0.jar:3.3.0]
at org.htmlunit.WebClient.getPage(WebClient.java:392) ~[htmlunit-3.3.0.jar:3.3.0]
at org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:647) ~[htmlunit3-driver-4.10.0.jar:?]
at org.openqa.selenium.htmlunit.HtmlUnitDriver.lambda$get$7(HtmlUnitDriver.java:627) ~[htmlunit3-driver-4.10.0.jar:?]
at org.openqa.selenium.htmlunit.HtmlUnitDriver.lambda$runAsync$0(HtmlUnitDriver.java:353) ~[htmlunit3-driver-4.10.0.jar:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:829) [?:?]
```
Here is the code:
```java
// javascript support enabled
HtmlUnitDriver driver = new HtmlUnitDriver(true);
driver.get("https://www.jitakong.com/jianpu/36528.html");
WebElement elem = driver.findElement(By.cssSelector("div.entry-main > div.entry-content > figure > a"));
System.out.println(elem.getAttribute("innerHTML"));
driver.close();
```
I have to have the javascript support enabled, else won't find the designated element.
But because of the JavaScript exception, the program just aborted.
--
Reply to this email directly or view it on GitHub:
#131
You are receiving this because you are subscribed to this thread.
Message ID: ***@***.***>
|
Thanks @rbri, I'm new to this, and am not able to find which package to PS. Trying to solve that problem myself while not having any IDE seems impossible. |
NVM, I found them, and it works like a charm. Thanks @rbri |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hope there is way to enable javascript support but ignore all its errors.
I'm getting
Error during JavaScript execution
on googlesyndication:Here is the code:
I have to have the javascript support enabled, else won't find the designated element.
But because of the JavaScript exception, the program just aborted.
The text was updated successfully, but these errors were encountered: