Applescript do javascript submit in safari
Hi,
I have a script that is supposed to do a bunch of stuffs on safari like ticking radio boxes and all, saving then submitting.
However, upon clicking the submit button - manually / with script, there'll be a pop up window with options " OK or Cancel ".
tell application "Safari"
-- this triggers the pop up window
do JavaScript ("document.getElementById('submitButton').click()") in document 1
-- trying to click the ok button using whatever knowledge I know
tell application "System Events" to key code 36
tell application "System Events" to tell process "Safari"
if exists (button "OK" of window 1) then
click (button "OK" of window 1)
end if
end tell
I think the main problem is the script "waits" at the do Javascript line for a response of an OK or cancel before it continues running the rest of the script like hitting enter or clicking the OK/ cancel. It is not a new window, and the pop up window cannot be dragged/moved.
Is there a way to solve this?
OS X El Capitan (10.11.4), null