AppleScript click on button (chrome) Here is the HTML tag of the button I would like to click using AppleScript.

&lt;button class="btn btn-primary" autofocus="" ng-click="ok()" tabindex="0"&gt;&lt;!-- ngIf: !isTranslate --&gt;&lt;span ng-if="!isTranslate" class="ng-scope"&gt;OK&lt;/span&gt;&lt;!-- end ngIf: !isTranslate --&gt; &lt;!-- ngIf: isTranslate --&gt;&lt;/button


Here is my script

tell application "Google Chrome"
    tell tab 2 of window 1 to set clickOnMyButton to execute javascript "document.getElementsByClassName('ng-scope')[0].click();"
end tell


Result:


  missing value


how can I generate a click ?

Update : I found that this is causing the block 

 style="z-index: 1050; display: block;"


Full HTML block

&lt;div tabindex="-1" role="dialog" class="modal fade ng-isolate-scope in" ng-class="{in: animate}" ng-style="{'z-index': 1050 + index*10, display: 'block'}" ng-click="close($event)" modal-window="" size="sm" index="0" animate="animate" style="z-index: 1050; display: block;"&gt;
    &lt;div class="modal-dialog modal-sm" ng-class="{'modal-sm': size == 'sm', 'modal-lg': size == 'lg'}"&gt;&lt;div class="modal-content" modal-transclude=""&gt;&lt;div class="modal-header ng-scope"&gt;&lt;span class="information-icon glyphicon glyphicon-info-sign"&gt;&lt;/span&gt; &lt;!-- ngIf: !isTranslate --&gt;&lt;span class="information-header ng-scope" ng-if="!isTranslate"&gt;Information&lt;/span&gt;&lt;!-- end ngIf: !isTranslate --&gt; &lt;!-- ngIf: isTranslate --&gt;&lt;/div&gt;&lt;div class="ng-scope"&gt;&lt;span class="glyphicon modal-body glyphicon-menu-down" ng-class="{ 'glyphicon-menu-down' : !errorDetails, 'glyphicon-menu-right' : errorDetails}" ng-click="errorDetails = !errorDetails" tabindex="0"&gt;&lt;/span&gt;&lt;!-- ngIf: !isTranslate --&gt;&lt;span ng-if="!isTranslate" class="ng-scope"&gt;Details&lt;/span&gt;&lt;!-- end ngIf: !isTranslate --&gt; &lt;!-- ngIf: isTranslate --&gt;&lt;/div&gt;&lt;!-- ngIf: !errorBullets --&gt;&lt;div ng-if="!errorBullets" collapse="errorDetails" class="ng-scope collapse in" style="height: auto;"&gt;&lt;ul&gt;&lt;li class="ng-binding"&gt;Please provide Purchase data&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;!-- end ngIf: !errorBullets --&gt;&lt;!-- ngIf: errorBullets --&gt;&lt;div class="modal-footer ng-scope"&gt;&lt;button class="btn btn-primary" autofocus="" ng-click="ok()" tabindex="0"&gt;&lt;!-- ngIf: !isTranslate --&gt;&lt;span ng-if="!isTranslate" class="ng-scope"&gt;OK&lt;/span&gt;&lt;!-- end ngIf: !isTranslate --&gt; &lt;!-- ngIf: isTranslate --&gt;&lt;/button&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;


If I can't click on the menu, how can I remove this using AppleScript?
It might be generating a click that you aren't capturing.


Inserted your exact markup with Chrome DevTools (to this page)
Added onclick="alert('!');" to the button
Ran your exact script in Script Editor
Got "!" alert dialog