You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to setting proxy authorization with username/passwd in ubuntu-server 18.04 env #132
Run before code will take exception like below:
......
Caused by: net.sourceforge.htmlunit.corejs.javascript.EvaluatorException: invalid property id (https://developer.apple.com/tutorials/js/chunk-vendors.fc64ed7e.js#10)
at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory$HtmlUnitErrorReporter.error(HtmlUnitContextFactory.java:435)
at net.sourceforge.htmlunit.corejs.javascript.Parser.addError(Parser.java:257)
at net.sourceforge.htmlunit.corejs.javascript.Parser.reportError(Parser.java:336)
at net.sourceforge.htmlunit.corejs.javascript.Parser.reportError(Parser.java:327)
at net.sourceforge.htmlunit.corejs.javascript.Parser.reportError(Parser.java:320)
at net.sourceforge.htmlunit.corejs.javascript.Parser.objectLiteral(Parser.java:3499)
......
Had a deeper look and there are several problems with this page. Long story short - HtmlUnit does not support the whole modern javascript syntay (because it is based on Rhino). We are working on improving this but i fear there is no real progress until the end of this year.
Two options: help us to improve Rhino or use selenium with real browsers
Had a deeper look and there are several problems with this page. Long story short - HtmlUnit does not support the whole modern javascript syntay (because it is based on Rhino). We are working on improving this but i fear there is no real progress until the end of this year.
Two options: help us to improve Rhino or use selenium with real browsers
Got it! I also check if i can make contribution on HtmlUitl to improve this issue.
Activity
rbri commentedon Jun 24, 2023
Looks like there is something missing ;-) will have a deeper look
rbri commentedon Jun 24, 2023
As a workaround can you please try something like
luorixiangyang commentedon Jun 24, 2023
Here is the detail infos:
pom.xml dependency like below:
...
org.seleniumhq.selenium
selenium-java
4.10.0
org.seleniumhq.selenium
htmlunit-driver
4.10.0
...
source code like below:
public static WebDriver createProxyWebDriver() {
String PROXY_HOST = ProxyHost;
int PROXY_PORT = ProxyPort;
public static String getPageOnDynamicWeb(String url) {
WebDriver client = createProxyWebDriver();
client.get(url);
String response = client.getPageSource();
client.close();
return response;
}
public static void main(String[] args) throws Exception {
String response = "";
String url = "https://developer.apple.com/documentation/accelerate/bnns/shape/3656199-init"; // the target url
response = getPageOnDynamicWeb(url);
ClearInnerToWriteFile(
"/home/luori/_fly/workspaces/javaworkspace/selenium-base/logs/apple_api_page_html.html",
response);
}
Run before code will take exception like below:
......
Caused by: net.sourceforge.htmlunit.corejs.javascript.EvaluatorException: invalid property id (https://developer.apple.com/tutorials/js/chunk-vendors.fc64ed7e.js#10)
at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory$HtmlUnitErrorReporter.error(HtmlUnitContextFactory.java:435)
at net.sourceforge.htmlunit.corejs.javascript.Parser.addError(Parser.java:257)
at net.sourceforge.htmlunit.corejs.javascript.Parser.reportError(Parser.java:336)
at net.sourceforge.htmlunit.corejs.javascript.Parser.reportError(Parser.java:327)
at net.sourceforge.htmlunit.corejs.javascript.Parser.reportError(Parser.java:320)
at net.sourceforge.htmlunit.corejs.javascript.Parser.objectLiteral(Parser.java:3499)
......
luorixiangyang commentedon Jun 24, 2023
Environment:
Ubuntu-server 18.04
google-chrome: Google Chrome 114.0.5735.133
ChromeDriver:114.0.5735.90
JDK:1.8.0_271
luorixiangyang commentedon Jun 24, 2023
Please try target url :https://developer.apple.com/documentation/accelerate/bnns/shape/3656199-init to test the correct approach .
Thanks!
luorixiangyang commentedon Jun 25, 2023
I need to point out :(https://developer.apple.com/documentation/accelerate/bnns/shape/3656199-init) is dynamic web content, need excute javascript file on scrape process. I can get the static web content but can't catch the dynamic parts.
rbri commentedon Jun 25, 2023
Had a deeper look and there are several problems with this page. Long story short - HtmlUnit does not support the whole modern javascript syntay (because it is based on Rhino). We are working on improving this but i fear there is no real progress until the end of this year.
Two options: help us to improve Rhino or use selenium with real browsers
luorixiangyang commentedon Jun 26, 2023
Got it! I also check if i can make contribution on HtmlUitl to improve this issue.