Making AppleScript fill form

天大地大妈咪最大 提交于 2019-12-19 10:52:57

问题


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

end tell


回答1:


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

... and use the same form id for the 'password' field and other fields.

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


来源:https://stackoverflow.com/questions/22615180/making-applescript-fill-form

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!