title: Caused by: com.intuit.karate.exception.KarateException: ReferenceError: "XMLHttpRequest" is not defined Exception in Karate config js file
body: <p>I want to load my configurations from server but when I am doing using </p>
  
  <p>XMLHttpRequest I  am getting Exception </p>
  
  <blockquote>
    <p>ava.lang.RuntimeException: evaluation of 'karate-config.js' failed
            at com.intuit.karate.ScenarioContext.(ScenarioContext.java:211)
            at com.intuit.karate.StepActions.(StepActions.java:50)
            at com.intuit.karate.core.FeatureExecutionUnit.submit(FeatureExecutionUnit.java:85)
            at com.intuit.karate.cucumber.CucumberRunner.callAsync(CucumberRunner.java:191)
            at com.intuit.karate.gatling.KarateAction.execute(KarateAction.scala:62)
            at io.gatling.core.action.Action.$bang(Action.scala:35)
            at io.gatling.core.action.Action.$bang$(Action.scala:35)
            at com.intuit.karate.gatling.KarateAction.io$gatling$core$action$ChainableAction$$super$$bang(KarateAction.scala:26)
            at io.gatling.core.action.ChainableAction.$bang(Action.scala:60)
            at io.gatling.core.action.ChainableAction.$bang$(Action.scala:58)
            at com.intuit.karate.gatling.KarateAction.io$gatling$core$action$ExitableAction$$super$$bang(KarateAction.scala:26)
            at io.gatling.core.action.ExitableAction.$bang(BlockExit.scala:137)
            at io.gatling.core.action.ExitableAction.$bang$(BlockExit.scala:135)
            at com.intuit.karate.gatling.KarateAction.$bang(KarateAction.scala:26)
            at io.gatling.core.controller.inject.Injector.startUser(Injector.scala:130)
            at io.gatling.core.controller.inject.Injector.injectUser(Injector.scala:140)
            at io.gatling.core.controller.inject.Injector.$anonfun$injectStreams$2(Injector.scala:120)
            at io.gatling.core.controller.inject.Injector.$anonfun$injectStreams$2$adapted(Injector.scala:120)
            at io.gatling.core.controller.inject.UserStream.withStream(Injector.scala:61)
            at io.gatling.core.controller.inject.Injector.$anonfun$injectStreams$1(Injector.scala:120)
            at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:234)
            at scala.collection.Iterator.foreach(Iterator.scala:929)
            at scala.collection.Iterator.foreach$(Iterator.scala:929)
            at scala.collection.AbstractIterator.foreach(Iterator.scala:1417)
            at scala.collection.MapLike$DefaultValuesIterable.foreach(MapLike.scala:210)
            at scala.collection.TraversableLike.map(TraversableLike.scala:234)
            at scala.collection.TraversableLike.map$(TraversableLike.scala:227)
            at scala.collection.AbstractTraversable.map(Traversable.scala:104)
            at io.gatling.core.controller.inject.Injector.injectStreams(Injector.scala:120)
            at io.gatling.core.controller.inject.Injector.io$gatling$core$controller$inject$Injector$$inject(Injector.scala:106)
            at io.gatling.core.controller.inject.Injector$$anonfun$1.applyOrElse(Injector.scala:151)
            at io.gatling.core.controller.inject.Injector$$anonfun$1.applyOrElse(Injector.scala:148)
            at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:34)
            at akka.actor.FSM.processEvent(FSM.scala:665)
            at akka.actor.FSM.processEvent$(FSM.scala:662)
            at io.gatling.core.controller.inject.InjectorFSM.processEvent(InjectorFSM.scala:34)
            at akka.actor.FSM.akka$actor$FSM$$processMsg(FSM.scala:659)
            at akka.actor.FSM$$anonfun$receive$1.applyOrElse(FSM.scala:653)
            at akka.actor.Actor.aroundReceive(Actor.scala:514)
            at akka.actor.Actor.aroundReceive$(Actor.scala:512)
            at io.gatling.core.akka.BaseActor.aroundReceive(BaseActor.scala:23)
            at akka.actor.ActorCell.receiveMessage(ActorCell.scala:527)
            at akka.actor.ActorCell.invoke(ActorCell.scala:496)
            at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257)
            at akka.dispatch.Mailbox.run(Mailbox.scala:224)
            at akka.dispatch.Mailbox.exec(Mailbox.scala:234)
            at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
            at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
            at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
            at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
    Caused by: com.intuit.karate.exception.KarateException: javascript
    function call failed: ReferenceError: "XMLHttpRequest" is not defined
            at com.intuit.karate.Script.evalFunctionCall(Script.java:1636)
            at com.intuit.karate.Script.call(Script.java:1587)
            at com.intuit.karate.Script.callAndUpdateConfigAndAlsoVarsIfMapReturned(Script.java:1709)
            at com.intuit.karate.ScenarioContext.(ScenarioContext.java:206)</p>
  </blockquote>
  
  <hr>
  
  <p>My config File Code :</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>function () {
      var System = Java.type('java.lang.System');
      var env = System.getProperty("profile");
      if (!env) {
          karate.log('env is not defined.')
          env = 'dev';
      }
      var request = new XMLHttpRequest();
      request.open("GET", "http://www.testsite.com",false);
      request.send();
      var result = request.responseText;
      console.log(result);
      return result
  }</code></pre>
  </div>
  </div>
  </p>