2014-08-28 57 views
0

我試圖讓AppleScript單擊頁面上的按鈕,但它不起作用。我一直在'do'後面收到錯誤「預計行結束但找到了標識符」。錯誤,「預計行結束但找到標識符。」

下面的代碼:

tell application "Firefox" 
    activate 
    open location "https://habitrpg.com/static/front" 
end tell 
delay 3 
tell application "Firefox" 
    do JavaScript "document.getElementsById('frontpage-play-button').click();" in current tab of first window 
end tell 

我要去哪裏錯了嗎? 在此先感謝!

回答

0

Firefox限制了applescript的支持,所以這些命令不會編譯。

也是JavaScript是稍微偏離,應該用getElementsById

你可以嘗試Safari瀏覽器來代替。

e.g,

tell application "Safari" 
    activate 
    open location "https://habitrpg.com/static/front" 
end tell 
delay 5 
tell application "Safari" 
    activate 
    do JavaScript "document.getElementById('frontpage-play-button').click();" in current tab of front window 
end tell