【问题标题】:Making AppleScript fill form制作 AppleScript 填写表格
【发布时间】:2014-03-29 16:03:42
【问题描述】:

我遇到的问题是让我恶心。我正在处理一个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

说完

【问题讨论】:

  • 问题不只是时间问题,因为如果我加载那个 url,然后只运行你的 do javascript 行,它仍然不起作用。你确定这是正确的网址,顺便说一句?您可以尝试另一种方法,即自己创建表单并提交。见这里:stackoverflow.com/questions/21414846/…

标签: applescript


【解决方案1】:

看起来您只是将表单 ID/层次结构错误。这对我有用:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-16
    • 2015-03-04
    • 2016-04-05
    • 1970-01-01
    • 2023-03-09
    • 2013-08-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多