Menu

#1650 SyntaxError: An invalid or illegal string was specified

Latest SVN
closed
nobody
None
1
2016-02-24
2014-10-23
No

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 ========

Discussion

  • Gavin Rifkind

    Gavin Rifkind - 2014-10-23

    I made a mistake with the Milestone, it is not Laatest SVN, it is 2.15

     
  • Ahmed Ashour

    Ahmed Ashour - 2014-10-23

    Can you provide a sample case to check?

     
  • Gavin Rifkind

    Gavin Rifkind - 2014-10-23

    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.

     
  • Ahmed Ashour

    Ahmed Ashour - 2014-10-23

    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).

     
  • Gavin Rifkind

    Gavin Rifkind - 2014-10-23

    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.

        public static void main(String[] args) {
            try {
                final WebClient webClient = new WebClient(BrowserVersion.CHROME);
    
                webClient.getOptions().setUseInsecureSSL(true);
                webClient.getOptions().setAppletEnabled(false);
    
                final HtmlPage page = webClient.getPage("https://adwords.google.com");
                HtmlTextInput email = null;
                HtmlPasswordInput password = null;
                HtmlSubmitInput loginBtn = null;
                DomElement element = page.getElementById("Email");
                if (element instanceof HtmlTextInput) {
                    email = (HtmlTextInput)element;
                }
    
                element = page.getElementById("Passwd");
                if (element instanceof HtmlPasswordInput) {
                    password = (HtmlPasswordInput)element;
                }
    
                element = page.getElementById("signIn");
                if (element instanceof HtmlSubmitInput) {
                    loginBtn = (HtmlSubmitInput)element;
                }
    
                String emailAddressVal = [enter email address here];
                String passwordVal = [enter password here];
    
                if (email != null && password != null && loginBtn != null) {
                    email.setValueAttribute(emailAddressVal);
                    password.setValueAttribute(passwordVal);
                    HtmlPage loggedIn = loginBtn.click();
                    int runningScripts = webClient.waitForBackgroundJavaScriptStartingBefore(20000);
                }
    
                webClient.closeAllWindows();
    
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    
     
  • RBRi

    RBRi - 2016-02-24
    • status: open --> closed
     
  • RBRi

    RBRi - 2016-02-24

    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.

     

Log in to post a comment.

MongoDB Logo MongoDB