制作 AppleScript 填写表单 [英] Making AppleScript fill form
问题描述
我遇到的问题是让我生病.我正在处理一个抛出动作来填写表单的applescript.我想我在让它等待网站 100% 加载时遇到了问题.该脚本激活站点但不填写表格.请导航并帮助解决这个懒惰的脚本:
the problem I'm having is making me sick. I'm working over an applescript that throws action to fill form. I think I'm having an issue while getting it to wait until the site is loaded in 100%. The script activates the site but doesn't fill the forms. Please navigate me and help to work out this lazy script:
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
结束告诉
推荐答案
看起来您只是表单 ID/层次结构错误.这对我有用:
Looks like you simply have the form id/hierarchy wrong. This worked for me:
tell application "Safari"
do JavaScript "document.forms['registerform']['regusername'].value = '" & mylogin & "'" in document 1
end tell
... 并为密码"字段和其他字段使用相同的表单 ID.
... and use the same form id for the 'password' field and other fields.
或者你也可以这样做,只需要担心特定的元素 id:
or you can do this, too, and only worry about the specific element id:
tell application "Safari"
do JavaScript "document.getElementById('regusername').value = '" & mylogin & "'" in document 1
end tell
这篇关于制作 AppleScript 填写表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!