New to both JS and AppleScript!
The goal of the script is to click a button automatically within a web page using the Safari browser. I have gotten this to work successfully by using other JS methods (for example document.getElementByID(IDName).click();), however, I have to use the title of the button instead, since the ID for the button in this webpage is generated daily (meaning that the ID changes).
I have tested within the browser that
document.querySelector('[title="Move to Next Day"]').click(); works to click the button, but getting it to work in my apple script has been an issue.
With my current code below I get an error that says, Expected “,” or “)” but found property. for the last line of code.
Here is my script:
to clickID(theId)
tell application "Safari"
do JavaScript "document.querySelector('" & theId & "').click();" in document 1
end tell
end clickID
clickID('"[title="Move to Next Day"]"')