JavaScript executado pelo AppleScript para clicar no botão e preencher o texto no Safari

1

Não estou mais conseguindo executar JavaScript no Safari.

Eu tenho esse script de trabalho para o Chrome.

set caseID to "11111"
end tell


####################################### time #########
set myDate to date string of (current date)


set myTime to time string of (current date)

set myDateTime to myDate & " - " & myTime


set textToSave to "MY TEXT HERE
HERE
HERE
" & myDateTime

tell application "Google Chrome"
    delay 0.1
    execute front window's active tab javascript "document.getElementsByName('9.9.5.4.5.CSInfoInspector.1.1.1')[0].click();"
    delay 0.1
    execute front window's active tab javascript "document.getElementsByName('05.5.54.5.CSInfoInspector.1.1.5.41.3.7.57.1')[0].value=" & quoted form of textToSave 
    delay 0.1
    execute front window's active tab javascript "document.getElementsByName('5.5.4.5.5.CSInspector.5.1.7')[0].value=" & quoted form of caseID

end tell

Eu converti para o Safari aqui:

set caseID to "11111"

####################################### time #########
set myDate to date string of (current date)


set myTime to time string of (current date)

set myDateTime to myDate & " - " & myTime


set textToSave to "MY TEXT HERE
HERE
HERE
" & myDateTime

tell application "Safari"
    delay 0.1
    do JavaScript "document.getElementsByName('9.9.5.4.5.CSInfoInspector.1.1.1')[0].click();" in current tab of window 1
    delay 0.1

    do JavaScript "document.getElementsByName('05.5.54.5.CSInfoInspector.1.1.5.41.3.7.57.1')[0].value=" & quoted form of textToSave in current tab of window 1

    do JavaScript "document.getElementsByName('5.5.4.5.5.CSInspector.5.1.7')[0].value=" & quoted form of caseID in current tab of window 1

end tell

O resultado retorna no AppleScript, mas o Safari não executa nenhuma ação Resultado: "11111"

Basicamente, o script deve clicar em um botão para abrir uma janela pop-up e preencher o texto O que estou fazendo de errado?

Meu sistema:
OS X 10.13.2 (17C202)
Safari Versão 11.0.2 (13604.4.7.1.5)

Kevin
fonte

Respostas:

1

Portanto, diferente do Chrome, onde você pode adicionar apenas algumas linhas com diferentes códigos JS, no safari você deve adicionar para cada código o JavaScript e mencionar o documento / guia

por exemplo :

tell application "Safari"
    delay 0.1
    do JavaScript "document.getElementById('accountEnabledSelection').value=1" in current tab of window 1
    do JavaScript "document.getElementsByName('demo')[0].click();" in current tab of window 1


end tell
Kevin
fonte