How to click the OK button in Google Chrome alert, using AppleScript
You can use a function on window.alert to intercept any alert and to cancel this alert, use a variable to see if there was an alert attempt.

Like this :

tell application "Google Chrome"
    -- Go to the website with the javascript button
    set myurl to "http://t4t5.github.io/sweetalert/"
    open location myurl
    delay 1
    tell active tab of window 1
        -- Click the normal javascript button on the page
        set popupAlert to execute javascript "var isAlert=false; (function() {window.alert = function() {isAlert=true; return;};})(); document.getElementsByTagName('button')[1].click(); isAlert"
        if popupAlert = "true" then -- This page has attempted to display an alert.
            do shell script "echo 'Issue with github.io' &gt; templog.txt"
        else -- no alert, continue
            -- This clicks the save button
        end if
    end tell
    -- Delete the tab when done
    delete (get active tab of window 1)
end tell