Click on a button (that is not a button ?) with Applescript or Javascript Okay, relative newbie here, but I have searched all the answers and tried most of the suggestions and cannot find a way to automate using Applescript or Javascript within Applescript to click a button on a specific website. I can't provide the website because it is part of a protected medical record software, but as far as I can tell the button is encoded as follows:

  &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;i class="icon-plus"&gt;&lt;/i&gt;
            &lt;span&gt;Add Files&lt;/span&gt;
            &lt;input type="file" name="files[]" multiple=""&gt;
        &lt;/span&gt;
    &lt;/h3&gt;


I have tried most of the Javascript (and Applescript) solutions. I have even tried the Fake app which seems to work for every other button except this one. I have searched in vain for a button id and the above code seems to be all that refers to the button. The function of the button is to bring up a Chooser window import image files.

Using tab to get to the button doesn't work because the number of tabs varies with individual patients (dynamic website ?).

I apologize in advance if this is trivial, but it is literally the last step in a long series of steps that would save me a lot of time. I figured out everything else mainly with the help on this board. 



Thanks to all of you.
I found my own answer by digging a little deeper into this. 

tell application "Safari"


do JavaScript "document.getElementsByName('files[]')[0].click();" in document 1


end tell


Using getElementsByName and the name attribute 'files[]' was all it took (and by the way was the ONLY way out many, many that worked in this case).