Is it possible with AppleScript to choose a clickable element in a web page and click it and if so, can you give me an example?
Yes, generally speaking, it's possible, however it can depend on the browser and the web page, there is no one method fits all, if you will.
Using this particular web page, looking at the question title line, to the far right is a blue button with says: Ask Question
With Google Chrome the following example AppleScript code does the same thing, without having to modify any of the default settings:
UI Scripting example:
On my system, in macOS High Sierra using Safari, version 11.1.1 (13605.2.8), the following example AppleScript code works to click the button that the other examples click.
tell application "System Events" to click UI element ¬ "Ask Question" of group 5 of UI element 1 of scroll area 1 of group 1 of ¬ group 1 of tab group 1 of splitter group 1 of window 1 of application process "Safari"
On my system, in Safari on macOS Catalina you'd have to change
of group 5 of UI element 1 to
This wouldn't work in Google Chrome as it does not expose that particular
UI element to click in this manner.
By the way, none of this is doable in Firefox.