title: Do JavaScript in AppleScript works on Safari but not Chrome
body: <p>I have a little AppleScript with embedded Javascript that works fine on Safari, but not on Chrome.</p>
  
  <p>The Safari version(non relevant portions deleted):</p>
  
  <pre><code>    tell application "Safari"
      activate
          do JavaScript "document.getElementsByName('files[]')[0].click();" in document 1 
      end tell
  </code></pre>
  
  <p>The Chrome version:</p>
  
  <pre><code>    tell application "Google Chrome"
      activate
  
      tell window 1 to tell tab 1
  
          execute  javascript "document.getElementsByName('files[]')[0].click();"
  
      end tell
  </code></pre>
  
  <p>The chrome version returns "missing value" in Apple ScriptEditor.</p>
  
  <p>I CAN get other javascript commands to work and I can get </p>
  
  <pre><code>document.getElementsByName('files[]')[0].click();
  </code></pre>
  
  <p>or</p>
  
  <pre><code>document.getElementsByName("files[]")[0].click();"
  </code></pre>
  
  <p>in the Chrome console when on the proper webpage (thought it may have something to do with double quotes - still could be I suppose).</p>
  
  <p>Here is the element in question:</p>
  
  <pre><code>&lt;h3&gt;Add new documents for this patient
           &lt;!-- The fileinput-button span is used to style the file input field as button --&gt;
          &lt;span class="btn fileinput-button" style="float: right !important;"&gt;
              &lt;span&gt;Select Files to Upload&lt;/span&gt;
              &lt;input type="file" name="files[]" multiple=""&gt;
          &lt;/span&gt;
      &lt;/h3&gt;
  </code></pre>
  
  <p>Any ideas? I have tried so many iterations of this.</p>
  
  <pre><code>document.getElementsByClassName('btn fileinput-button')[0].children[1].click();
  </code></pre>
  
  <p>works in the console, but not when in AppleScript. Seems like AppleScript weirdness to me, but...</p>
  
  <p>Added information:</p>
  
  <p>I can get a "click" on the logon page, so it isn't a site wide issue...</p>
  
  <pre><code>tell window 1 to tell tab 1
  
              execute javascript "document.getElementById('username').value='someLoser';"
              execute javascript "document.getElementById('password').value='YouWish'"
              execute javascript "document.getElementsByClassName('btn btn-md btn-primary')[0].click();"
  
          end tell
  </code></pre>
  
  <p>works fine embedded in AppleScript.</p>
  
  <p>Thanks.</p>