2016-03-26 29 views
0

我在編碼方面很新穎,尤其是在蘋果腳本。我設法讓下面的代碼工作:Applescript:重複,直到reCaptcha發生

tell application "Safari" 

    repeat 
     delay 7.5 
     set the URL of document 1 to "https://url.com" 
     delay 2 
     tell document 1 
      do JavaScript "document.getElementById(\"id1\").click()" 
      do JavaScript "document.getElementById(\"id2\").click()" 
      do JavaScript "document.getElementById(\"id3\").click()" 
      do JavaScript "document.getElementById(\"id4\").click()" 
      do JavaScript "document.getElementById(\"id5\").click()" 
      do JavaScript "document.getElementById(\"id6\").click()" 
      delay 0.25 
     end tell 
     tell application "Safari" 
      activate 
     end tell 

     tell application "System Events" 
      delay 0.25 
      tell process "Safari" to key code 48 
      delay 0.5 
      key code 21 

     end tell 

     delay 0.25 

     tell application "Safari" 

      tell document 1 
       do JavaScript "document.getElementById(\"book\").click()" 

      end tell 
     end tell 
    end repeat 

end tell 

而不是重複的代碼所有的時間,我想,直到谷歌驗證碼時,其最後的JavaScript操作後彈出,使代碼重複。

回答

0

我的建議是調整你重複的語句是這樣的...

set done to false 
repeat while not done 

    if reCaptcha = "something" then 
     set done to true 
    end if 
end repeat 
+0

我仍然不知道我應該插入用於「東西」 –

+0

「東西」是無論你測試。您正試圖測試驗證碼是否已更改?我不完全明白你想要做什麼。我只是在幫助腳本的「重複」部分。 – ThrowBackDewd