Safari 中的 getElementById

getElementById in Safari

我想使用 AppleScript 和 Safari 下载我的电子报。这是我的代码:

tell application "Safari"
    activate
    make new document with properties {URL:"https://kundenkonto.mittelbayerische.de/frontend/login.php?service=http://epaper.mittelbayerische.de/edition-mbz/index2.jsp%3Flang%3Dde"}
    delay 5
tell document 1
    do JavaScript "document.getElementById('submit_btn').click()"
    delay 5
    do JavaScript "loadEditionPDF();"
end tell
end tell

加载站点,Safari 自动填写登录凭据,但随后停止在 "document.getElementById('submit_btn').click()" 和 "missing value"。

我做错了什么?

您需要转到元素的子节点,这样才能正常工作。

tell application "Safari"
activate
make new document with properties {URL:"https://kundenkonto.mittelbayerische.de/frontend/login.php?service=http://epaper.mittelbayerische.de/edition-mbz/index2.jsp%3Flang%3Dde"}
delay 5
tell document 1
    do JavaScript "document.getElementById('submit_btn').childNodes[0].click()"
    delay 5
    do JavaScript "loadEditionPDF();"
end tell
end tell