getElementById not working with AppleScript I'm trying to automate a click on a radio button by id. Using syntax I've found online I've created this script but it's not selecting the radio button. Can anyone correct me?

# Launch a new private window
tell application "System Events"
    tell process "Safari"
        tell menu bar 1
            click menu bar item "File"
            tell menu "File"
                click menu item "New Private Window"
            end tell
        end tell
    end tell
end tell

tell application "Safari"
    open location "https://www.nngroup.com/articles/checkboxes-vs-radio-buttons/"
    delay 3
    tell application "System Events" to keystroke space
    do JavaScript "document.getElementById('two').click();"
end tell
Close you need to specify who to tell, in this case document 1

tell application "System Events"
    tell process "Safari"
        tell menu bar 1
            click menu bar item "File"
            tell menu "File"
                click menu item "New Private Window"
            end tell
        end tell
    end tell
end tell

tell application "Safari" 
    open location "https://www.nngroup.com/articles/checkboxes-vs-radio-buttons/"
    delay 3
    tell application "System Events" to keystroke space
    tell document 1
        do JavaScript "document.getElementById('two').click();"
    end tell
end tell


Also when working with radio buttons, I would suggest:

document.getElementById('two').checked = true;


Also you can escape quotes (don't need to in this example, but good to know)

do JavaScript "document.getElementById(\"two\").checked = true;"