title: How to use js variable from Java WebDriver on Firefox
body: <p>Main goal is to get javascript element <strong>authKey</strong> into Java code.
  Here is code:</p>
  
  <p>index.html:</p>
  
  <pre><code>...
        &lt;script type="text/javascript"&gt;
  
          var params = {
              authKey: "abc"
          };
  
          Main.init("#content", params);
      &lt;/script&gt;
  ...
  </code></pre>
  
  <p>main.java:</p>
  
  <pre><code>    public static void main(String[] args) throws InterruptedException {
  
          WebDriver d = new FirefoxDriver();
          d.get("***/index.html");
     //     System.out.println(" var " + d.findElement(By.xpath("/html/body/script[3]")));
          Thread.sleep(3000);
          JavascriptExecutor jse = (JavascriptExecutor) d;
  //        System.out.println(jse.executeAsyncScript("document.URL"));
          Object val = jse.executeScript("return params.authKey;");
          d.quit();
      }
  </code></pre>
  
  <p>I'm always getting something like: </p>
  
  <pre><code>Exception in thread "main" org.openqa.selenium.JavascriptException: ReferenceError: **params is not defined**
  Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700'
  System info: host: 'Mikhails-MacBook-Pro.local', ip: '10.10.20.139', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_111'
  Driver info: org.openqa.selenium.firefox.FirefoxDriver
  </code></pre>
  
  <p>I've tried different ways to get this authKey parameter, without return, as function, but still nothing... Could someone help with that?</p>
  
  <p>Thanks in advance.</p>
  
  <p>UPD: 
  Solution <a href="https://stackoverflow.com/a/40936063/6809155">https://stackoverflow.com/a/40936063/6809155</a> works, but still looking for native js solution to get exactly params.authKey parameter, because in future there could be a lot of params.  </p>