0
votes

I'm trying to get AppleScript to click on a button on a page, but it's not working. I keep getting the error "Expected end of line but found identifier" just after the 'do'.

Here's the code:

tell application "Firefox"
    activate
    open location "https://habitrpg.com/static/front"
end tell
delay 3
tell application "Firefox"
     do JavaScript "document.getElementsById('frontpage-play-button').click();" in current tab of first window
end tell

Where am I going wrong please? Thanks in advance!

1

1 Answers

0
votes

Firefox has limited applescript support so those commands won't compile.

Also that javascript was slightly off, should have used getElementsById

You could try Safari instead.

e.g,

tell application "Safari"
    activate
    open location "https://habitrpg.com/static/front"
end tell
delay 5
tell application "Safari"
    activate
    do JavaScript "document.getElementById('frontpage-play-button').click();" in current tab of front window
end tell