制作AppleScript填写表单

时间:2014-03-24 16:31:33

标签: applescript

我遇到的问题让我生病了。我正在研究一个可以填补表格的苹果。我认为我在让它等到网站100%加载时遇到问题。脚本激活网站但不填写表单。请导航我并帮助解决这个懒惰的脚本:

tell application "Safari"
set loginurl to "http://www.dogomania.pl/forum/register.php"
set mylogin to "worker100"
set mypassword to "blackie698"
tell application "Safari"
    make new document at end of documents
    set URL of document 1 to loginurl
    delay 4
    do JavaScript "document.forms['regusername']['username'].value = '" & mylogin & "'" in document 1
    do JavaScript "document.forms['password']['password'].value = '" & mypassword & "'" in document 1
end tell

告诉

1 个答案:

答案 0 :(得分:1)

看起来你只是表单id / hierarchy错误了。这对我有用:

tell application "Safari"
  do JavaScript "document.forms['registerform']['regusername'].value = '" & mylogin & "'" in document 1
end tell

...并使用相同的表单ID作为'密码'领域和其他领域。

或者你也可以这样做,只担心具体的元素id:

tell application "Safari"
    do JavaScript "document.getElementById('regusername').value = '" & mylogin & "'" in document 1
end tell