我正在编写Applescript实用程序来登录Facebook,执行一些简单的任务然后注销。除了退出外,我一切正常。我想使用Safari,推荐最可靠的方法是调用Javascript而不是使用系统事件。只要我可以退出用户,我就会接受任何一种方式。注销操作是我试图找到的一个menulist项目,但是使用此代码我得到“缺失值”。非常感谢您的帮助!
tell application "Safari"
if not (exists document 1) then reopen
tell document 1
set URL to "https://www.facebook.com"
delay 3
do JavaScript "document.getElementById('email').value='email-address';
document.getElementById('pass').value='password-value';
document.getElementById('loginbutton').click();
document.getElementById('persist_box').value='0';"
end tell
-- working code --
-- working code
-- Need to logout of this account
tell document 1
set URL to "https://www.facebook.com/logout.php"
delay 3
do JavaScript "document.getElementById('logout_form').childNodes[0].click();"
end tell
end tell
-- from the Facebook page View Code
-- role="menuitem"><form id="logout_form" method="post" action="https://www.facebook.com/logout.php"
onsubmit="return
答案 0 :(得分:0)
在别处找到帮助。这很有效!
tell application "Safari"
tell document 1
do JavaScript "document.getElementById('logout_form').submit()"
end tell
end tell