Hi I am writing an application which needs to automate some tasks on the Google AdWords website.
When I user BrowserVersion.CHROME, I get the exception below, if I use BrowserVersion.INTERNET_EXPLORER_11 then I don't get the exception
SEVERE: Job run failed with unexpected RuntimeException: Wrapped java.lang.Exception: SyntaxError: An invalid or illegal string was specified. (https://www.google.com/tools/feedback/chat_load.js#20)
======= EXCEPTION START ========
Exception class=[net.sourceforge.htmlunit.corejs.javascript.WrappedException]
com.gargoylesoftware.htmlunit.ScriptException: Wrapped java.lang.Exception: SyntaxError: An invalid or illegal string was specified. (https://www.google.com/tools/feedback/chat_load.js#20)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:705)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:620)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:513)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:637)
at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.setState(XMLHttpRequest.java:223)
at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.doSend(XMLHttpRequest.java:731)
at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.access$000(XMLHttpRequest.java:102)
at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest$1.run(XMLHttpRequest.java:611)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:620)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:513)
at com.gargoylesoftware.htmlunit.javascript.background.JavascriptXMLHttpRequestJob.run(JavascriptXMLHttpRequestJob.java:36)
at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl.runSingleJob(JavaScriptJobManagerImpl.java:328)
at com.gargoylesoftware.htmlunit.javascript.background.DefaultJavaScriptExecutor.run(DefaultJavaScriptExecutor.java:162)
at java.lang.Thread.run(Unknown Source)
Caused by: net.sourceforge.htmlunit.corejs.javascript.WrappedException: Wrapped java.lang.Exception: SyntaxError: An invalid or illegal string was specified. (https://www.google.com/tools/feedback/chat_load.js#20)
at net.sourceforge.htmlunit.corejs.javascript.Context.throwAsScriptRuntimeEx(Context.java:1907)
at com.gargoylesoftware.htmlunit.javascript.host.Window.postMessage(Window.java:2175)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.sourceforge.htmlunit.corejs.javascript.MemberBox.invoke(MemberBox.java:120)
at net.sourceforge.htmlunit.corejs.javascript.FunctionObject.call(FunctionObject.java:448)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1531)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:798)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:411)
at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:309)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3057)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:103)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$4.doRun(JavaScriptEngine.java:630)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:690)
... 13 more
Caused by: java.lang.Exception: SyntaxError: An invalid or illegal string was specified.
... 29 more
WrappedException: net.sourceforge.htmlunit.corejs.javascript.WrappedException: Wrapped java.lang.Exception: SyntaxError: An invalid or illegal string was specified. (https://www.google.com/tools/feedback/chat_load.js#20)
at net.sourceforge.htmlunit.corejs.javascript.Context.throwAsScriptRuntimeEx(Context.java:1907)
at com.gargoylesoftware.htmlunit.javascript.host.Window.postMessage(Window.java:2175)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.sourceforge.htmlunit.corejs.javascript.MemberBox.invoke(MemberBox.java:120)
at net.sourceforge.htmlunit.corejs.javascript.FunctionObject.call(FunctionObject.java:448)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1531)
at script(https://www.google.com/tools/feedback/chat_load.js:20)
at script(https://www.google.com/tools/feedback/chat_load.js:20)
at script(https://www.google.com/tools/feedback/chat_load.js:21)
at script.Ab(https://www.google.com/tools/feedback/chat_load.js:21)
at script.Nb(https://www.google.com/tools/feedback/chat_load.js:24)
at script.L(https://www.google.com/tools/feedback/chat_load.js:24)
at script(https://www.google.com/tools/feedback/chat_load.js:22)
at script(https://www.google.com/tools/feedback/chat_load.js:28)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:798)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:411)
at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:309)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3057)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:103)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$4.doRun(JavaScriptEngine.java:630)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:690)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:620)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:513)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:637)
at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.setState(XMLHttpRequest.java:223)
at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.doSend(XMLHttpRequest.java:731)
at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.access$000(XMLHttpRequest.java:102)
at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest$1.run(XMLHttpRequest.java:611)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:620)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:513)
at com.gargoylesoftware.htmlunit.javascript.background.JavascriptXMLHttpRequestJob.run(JavascriptXMLHttpRequestJob.java:36)
at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl.runSingleJob(JavaScriptJobManagerImpl.java:328)
at com.gargoylesoftware.htmlunit.javascript.background.DefaultJavaScriptExecutor.run(DefaultJavaScriptExecutor.java:162)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.Exception: SyntaxError: An invalid or illegal string was specified.
... 29 more
Inside wrapped exception:
java.lang.Exception: SyntaxError: An invalid or illegal string was specified.
at com.gargoylesoftware.htmlunit.javascript.host.Window.postMessage(Window.java:2175)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.sourceforge.htmlunit.corejs.javascript.MemberBox.invoke(MemberBox.java:120)
at net.sourceforge.htmlunit.corejs.javascript.FunctionObject.call(FunctionObject.java:448)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1531)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:798)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:411)
at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:309)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3057)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:103)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$4.doRun(JavaScriptEngine.java:630)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:690)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:620)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:513)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:637)
at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.setState(XMLHttpRequest.java:223)
at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.doSend(XMLHttpRequest.java:731)
at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.access$000(XMLHttpRequest.java:102)
at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest$1.run(XMLHttpRequest.java:611)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:620)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:513)
at com.gargoylesoftware.htmlunit.javascript.background.JavascriptXMLHttpRequestJob.run(JavascriptXMLHttpRequestJob.java:36)
at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl.runSingleJob(JavaScriptJobManagerImpl.java:328)
at com.gargoylesoftware.htmlunit.javascript.background.DefaultJavaScriptExecutor.run(DefaultJavaScriptExecutor.java:162)
at java.lang.Thread.run(Unknown Source)
== CALLING JAVASCRIPT ==
function () {
if (4 == g.readyState) {
m.clearTimeout(f);
var b;
!(b = lb(g.status)) && (b = 0 === g.status) && (b = Ub(a), b = !("http" == b || "https" == b || "" == b));
b ? c(g) : d(new bc(g.status, a));
}
}
======= EXCEPTION END ========
I made a mistake with the Milestone, it is not Laatest SVN, it is 2.15
Can you provide a sample case to check?
Unfortunately not.
The web site that I am connecting to is Google AdWords, and I am getting the error after logging in, so in order to reproduce it, I would need to give you my AdWords credentials, which I cannot do. I am new to HtmlUnit, so maybe you can give me some pointers as to how to extract the piece of Javascript that is failing, and then we can try to recreate a test case.
Then please use latest snapshot from build.canoo.com/htmlunit/artifacts/
And try to know which URL loads the JS:
https://www.google.com/tools/feedback/chat_load.js
you can print all URLs as hinted in http://htmlunit.sourceforge.net/faq.html#HowToModifyRequestOrResponse
Another way is to provide your code with dummy username/password, and the tester can use his own credentials (if that is possible by normal google username).
The way AdWords works, is that you can log in with your normal google username, however if that account is not already connected to an AdWords account, the first time you connect, you will need to go through the AdWords Account creation screen first.
So if you don't already have an AdWords account, you need to do the account creation process manually via a browser, before trying to execute the code.
With my user (without any campaign), I get:
Wrapped com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot call method "toLowerCase" of undefined (script in https://accounts.google.com/ServiceLogin?service=adwords&continue=https://adwords.google.com/um/identity?ltmpl%3Djfk%26hl%3Den_US&hl=en_US<mpl=jfk&passive=0&skipvpage=true from (2105, 32) to (2240, 10)#2205)
You can save the JavaScript seen by HtmlUnit by something like:
final WebClient client = new WebClient();
final WebConnection connection = new DebuggingWebConnection(client.getWebConnection(), "myTest");
client.setWebConnection(connection);
I have attached the javascript file that was created for
https://www.google.com/tools/feedback/chat_load.js
The error is slightly different now, it has https://www.google.com/tools/feedback/chat_load.js#724
Hope that can help you to reproduce the problem.
If not, you do not need to spend more time on it, I can continue what I need to do by using BrowserVersion.INTERNET_EXPLORER_11
This isssue is really old and in between the tested page and also our code base had seen major changes.
We have changed the error msg in a way to point to the real problem and provide as many info as possible to understand that problem.
Will close this. If there are still problems with this, please open a new one.