It’s just a button that’s doing nothing. Your script probably works but no function is or that we can see is assigned to the onClick event. Some sites doesn’t have submit buttons in their forms but outside it and the called function assigned after the dom is loaded. So when the DOM is loaded (the source code you’re looking at) it just looks like an orphaned button. The advantage is that most spider software that is grabbing web contents and fill forms with spams won’t work on those forms. You have to look deeper into the code and find what function or line of code is called when the user presses the button. Probably an event is added as event listener to your button after the DOM is loaded.
Keep in mind that this can be done by CSS of course.
But I have seen more complex tricks in the past. To keep spider software away, the parent element, in this case the div, contains an event listener. The button will behave the same way (press state) but the click is handled by another element and your attempt won’t work. If the parent div has actually an event listener you may need something like this:
tell application "Safari"
activate
do JavaScript "document.getElementById('validate-button-id').parentElement.click()" in document 1
end tell
So, off to accessibility inspector and the rather time consuming:
tell application "System Events"
click UI element 9 of UI element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window "bob" of process "Safari"
end tell
Once you get to UI element 1, System events doesn’t understand anything other than UI Elements, which makes it slightly easier once you know that!
Kind of… Useful in knowing how many levels I needed to go down. Useless once it got to the actual web page.
What I did, instead, was to start with a simple:
tell application "Safari" to activate
tell application "System Events"
tell process "Safari"
UI elements
end tell
end tell
This returns:
then repeating the process for every element that Accessibility Inspector told me about, resulting in the rather crazy:
tell application "Safari" to activate
tell application "System Events"
tell process "Safari"
tell front window
tell splitter group 1
tell tab group 1
tell group 1
tell group 1
tell scroll area 1
tell UI element 1
UI elements
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end tell
Using the Lock feature of AI told me that it was UI element 9
A shame that Safari doesn’t understand the UI elements within a web page, but fully understandable at the same time
can you provide the URL you want to click the button. We cannot help you any further this way because I believe it still can be done using JavaScript, and should be done that way.
Safari itself is nothing more than an application with a very large custom C++ written view (originally kHTML). Like image and video views the HTML view is a similar view that contains no object from the Cocoa API.