Safari에서 AppleScript를 사용하여 웹에 자동으로 로그인하고 싶습니다.AppleScript를 사용하여 대화 버튼을 자동으로 클릭하십시오.
URL을 열고 사용자 이름과 암호를 입력 할 때 처음 또는 아직 암호를 저장하지 않은 경우 "이 암호를 저장 하시겠습니까?"메시지가 표시됩니다.
"아니요"를 선택하려면 AppleScript를 사용하고 싶습니다. 어떻게해야합니까?
tell application "Safari"
open location "http://www.amazon.com"
activate
end tell
if page_loaded(60) then
say "Page Loaded"
tell application "Safari"
set loginURL to do JavaScript "document.getElementById('nav-your-account').getAttribute('href')" in document 1
open location loginURL
end tell
else
say "Page Failed to load or Safari didn't open"
end if
if page_loaded(60) then
say "Page Loaded"
tell application "Safari"
do JavaScript "document.getElementById('ap_email').value = 'mritjp'; document.getElementById('ap_password').value = 'mritjp'; document.forms['signIn'].submit();" in document 1
---HOW TO CONTROL TO CHOOSE "Not Now" in message "Would you like to save this password?" of safari
activate
delay 2
end tell
else
say "Page Failed to load or Safari didn't open"
end if
on page_loaded(timeout_value) -- in seconds
delay 1
repeat with i from 1 to timeout_value
tell application "Safari"
if name of current tab of window 1 is not "Loading" then exit repeat
end tell
delay 1
end repeat
if i is timeout_value then return false
tell application "Safari"
repeat until (do JavaScript "document.readyState" in document 1) is "complete"
delay 0.5
end repeat
end tell
return true
end page_loaded
Fixed by comment of Lauri Ranta : 여기
내 현재 코드입니다on enabledGUIScripting()
do shell script "sudo touch /private/var/db/.AccessibilityAPIEnabled" password "1" with administrator privileges
end enabledGUIScripting()
: 보조 장치에 대한 액세스가 시스템 환경 설정에서 활성화 된 경우
, 당신은 시스템 이벤트를 사용할 수 있습니다
다음 :
보조 장치에 대한 액세스가 시스템 환경 설정에서 사용하도록 설정 한 경우, 시스템 이벤트를 사용할 수 있습니다 17,451,515,tell application "System Events" to tell process "Safari"
click button 3 of sheet 1 of window 1
end tell
라 우리 란타의 대답은 문제의 해결책이라면, 다음의 답에 녹색 체크 표시를 클릭 그것을 받아 들인다. –