首页 > 解决方案 > 使用 AppleScript 输入用户名和密码

问题描述

我正在尝试登录 members.nwmls.com

我使用了以前工作过的代码按类和 ID 调用元素,但它们都不起作用。

有人可以帮我确定输入密码需要写入的参数吗?

to inputByID(theId, theValue) -- creates the function
    
    tell application "Safari" -- tells AppleScript to use Safari
        
        do JavaScript "  document.getElementsById('" & theId & "').value ='" & theValue & "';" in window 1 -- gets the ID that we specified and then inputs the value we specified into the  ourform
        
    end tell -- stops using safari
    
end inputByID --marks the end of the function


tell application "Safari"
    tell window 1
        set current tab to (make new tab with properties {URL:"http://members.nwmls.com"})
    end tell
    delay 1
    repeat until (do JavaScript "document.readyState" in document 1) is "complete"
    end repeat
    delay 5
    
    inputByID("clareity", "username")
    
end tell

谢谢

缺口

标签: passwordsapplescript

解决方案


推荐阅读