Release Automation

Expand all | Collapse all

Load XML using Execute Javascript Action

Jump to Best Answer
  • 1.  Load XML using Execute Javascript Action

    Posted 12-18-2017 02:28 AM

    Hi Experts,

     

    I am trying to load XML using the Execute Javascript Action. The XML file is in a local path in the server.

    I am getting error as : ReferenceError: "XMLHttpRequest" is not defined.

     Below is the logs in the nolio_action_exe.log. Please advise as how we can load XML.

     

    Code:

    function readXML(xmlFile) {

    var xml = new XMLHttpRequest();

    xml.open('GET', xmlFile, false);

    xml.send();

    var xmlData = xml.responseText;

    var str = xmlData.getElementByTagName("param-name");

    return str;

    }

    readXML(input1);

    output1 = str;

     

    Logs output:

     

    2017-12-18 12:12:08,343 [job-229495-jobServer-229537-6:Execute JavaScript code(P270.F13398.E13399):Execute JavaScript code] DEBUG (com.nolio.platform.shared.datamodel.Action:79) - Executing the following javascript: function readXML(xmlFile) {

    var xml = new XMLHttpRequest();

    xml.open('GET', xmlFile, false);

    xml.send();

    var xmlData = xml.responseText;

    var str = xmlData.getElementByTagName("param-name");

    return str;

    }

    readXML(input1);

    output1 = str;

    2017-12-18 12:12:08,386 [job-229495-jobServer-229537-6:Execute JavaScript code(P270.F13398.E13399):Execute JavaScript code] ERROR (com.nolio.platform.shared.datamodel.Action:122) - Script execution failed. Exception:

    javax.script.ScriptException: ReferenceError: "XMLHttpRequest" is not defined in <eval> at line number 2

            at jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:467)

            at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:451)

            at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:403)

            at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:399)

            at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:155)

            at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)

            at com.nolio.platform.shared.executables.actions.JavaScriptAction.execute(JavaScriptAction.java:108)

            at com.nolio.platform.shared.datamodel.ActionExecutionState.localExecution(ActionExecutionState.java:384)

            at com.nolio.platform.shared.datamodel.ActionExecutionState.access$500(ActionExecutionState.java:45)

            at com.nolio.platform.shared.datamodel.ActionExecutionState$2.execAction(ActionExecutionState.java:131)

            at com.nolio.platform.shared.datamodel.ActionExecutionState.exec(ActionExecutionState.java:401)

            at com.nolio.platform.shared.datamodel.Action.run(Action.java:229)

            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)

            at java.util.concurrent.FutureTask.run(FutureTask.java:266)

            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

            at com.nolio.platform.shared.flowcontrol.LocalFlowController$JobBoundThreadFactory$1.run(LocalFlowController.java:804)

            at java.lang.Thread.run(Thread.java:745)

    Caused by: <eval>:2 ReferenceError: "XMLHttpRequest" is not defined

            at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57)

            at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:319)

            at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:291)

            at jdk.nashorn.internal.objects.Global.__noSuchProperty__(Global.java:1428)

            at jdk.nashorn.internal.scripts.Script$Recompilation$4034$26A$\^eval\_.readXML(<eval>:2)

            at jdk.nashorn.internal.scripts.Script$4033$\^eval\_.:program(<eval>:9)

            at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:623)

            at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)

            at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)

            at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:446)

     

     

    Thanks & Regards

    Paneendra



  • 2.  Re: Load XML using Execute Javascript Action
    Best Answer

    Broadcom Employee
    Posted 12-22-2017 10:52 AM

    Hi 

     

    I think the "XMLHttpRequest" class is not a default java script object , 

    XMLHttpRequest is a built-in object in web browsers not in the default java script library 
    You may need to install manual a additional library will have a look if i can find how 
    Dirk 


  • 3.  Re: Load XML using Execute Javascript Action

    Posted 12-27-2017 02:09 AM

    Hi Dirk,

     

    Could you please take a look at this thread - 

     

    how can i enter value dynamically while lisa is running a test? 

     

    -Regards,

    Shashank



  • 4.  Re: Load XML using Execute Javascript Action

    Broadcom Employee
    Posted 01-02-2018 09:15 AM

    Hi
    I believe your questions has been answered, I will mark this as the correct answer.
    When your question is not answered or you still have additional questions please let us know.
    With Kind Regards

    Dirk