title: Getting an empty JavaScript Array in Java (Selenium test)
body: <p>I need to get an empty array declared in a JavaScript script in a Java variable.</p>
  
  <p>The JavaScript array is declared as so on a web page:</p>
  
  <pre><code>tc_vars["products"] = new Array();
  </code></pre>
  
  <p>(I only need the <code>products</code>'s array, not the <code>tc_vars</code> one).</p>
  
  <p>This is how I try to get this variable in Java :</p>
  
  <pre><code>Object[] value = (Object[]) js.executeScript("return tc_vars['products'];");
  </code></pre>
  
  <p>(Where <code>js</code> is a <code>JavascriptExecutor</code> associated with a Selenium <code>WebDriver</code>).</p>
  
  <p>I usually have no trouble using this method for getting Strings, but it seems it just won't work for an empty Array. Moreover, I don't have any error message, the WebDriver just crashes.</p>
  
  <p>The <code>executeScript</code> method returns an <code>Object</code> variable. Casting it to a <code>String</code> (when the JS variable is a String) works well, but I had no chance in casting this empty Array to <code>String[]</code> or <code>Object[]</code>.</p>