title: java selenium webdriver - how to output the attribute of a javascript object?
body: <p>I was wondering if anyone could help me find a way to output to the Eclipse console the results returned from executing a Javascript ?</p>
  
  <p>These are the steps I manually perform (that I would like to automate):</p>
  
  <ol>
  <li>Open test web page. </li>
  <li>Open Google chrome Javascript console </li>
  <li>Type "productObj.mainURL" and enter</li>
  </ol>
  
  <p>This will output to the Chrome Javascript console the URL value/attribute that I'm looking for.</p>
  
  <p>I've done a fair bit of research on my own, and I am stumped.</p>
  
  <p>I've tried the code below:</p>
  
  <pre><code>JavascriptExecutor js = (JavascriptExecutor) driver;
  String mainURL = (String) js.executeScript("productObj.mainURL");
  System.out.println(mainURL);
  </code></pre>
  
  <p>But all I get returned is a "null"...</p>
  
  <p>Any help please? </p>