Applescript/Javascript to click submenu item of Jupiter Notebook in Safari When I run a.ipynb jupyter notebook file in Safari, it opens at local host http://localhost:8888/notebooks/a.ipynb#.

NOTE: The script should work for any *.ipynb file, a.ipynb is just an example. Also, the website is at the frontmost app while running the code.

How can I write an Applescript (may be using JavaScript) so that I can click the menu Run All Below button in that tab of safari submenu ?



Here is my attemt:

tell application "Safari"

activate

end tell


tell application "System Events"

tell process "Safari"

click menu item "Run All Below" of menu "Cell" of menu bar 1

end tell

end tell


But, this did not work.  I am very new to applescript and generally only use Python.

How can I click the required menu "Run All Below" ? 

Related Links:
Using Javascript | Applescript to click button in Safari
https://stackoverflow.com/questions/24917282/click-on-safari-web-page-button-using-applescript
An easy way to do this is to use the Automator "Watch Me Do" feature, then convert it to Applescript.


Open the Automator app and create a new document.
Select "Workflow" as the document type.
Now make sure you have Safari open to the page you want it to.
Go back to Automator and click on "Record." There should be a small black window that pops up showing Automator is recording.
Go to Safari and do whatever action(s) you want to automate.
Stop the recording.
Go back to Automator and there should be a new action that looks somewhat like this:

You may need to adjust the playback speed using the slider to make it work properly
Now you can just leave it like this and convert it to an application so you can double-click it to run, or:
See here to convert it to AppleScript so you can use it in Script Editor