2017-05-09 3 views
0

AppleScriptを使用して強制的に登録しようとしています。電子メールを必要とするフォームフィールドがあります。私は正常にフォームフィールドに電子メールを追加していますが、それはまだ "値"として認識されません。要素を調べると、値は設定されません。しかし、フォームフィールドをクリックしてスペースを追加すると、値が認識されます。私はこれを回避する方法がわかりません。私はfocus()、click()、複数のキーストロークを使用しようとしましたが、私が何をしてもApplescriptを使用して値を設定することはありません。AppleScriptはJavaScript経由でWebフォームの入力フィールドに値を設定しました

set email to the text returned of (display dialog "Enter in Your Email to Validate Your Purchase:" default answer "") 

tell application "Safari" 
     make new document at end of documents 
     set URL of document 1 to "https://myurl.com" 
     tell application "System Events" 

      set theScript to "document.getElementById('email').value= '" & email & "';" 

     end tell 

     delay 3 

     do JavaScript theScript in document 1 

end tell 

答えて

0

私は答えを見つけた:

tell application "Safari" 
make new document at end of documents 
set URL of document 1 to "https://www.myurl.com" 

     delay 1 
     do JavaScript "document.getElementById('email').focus();" in document 1 
     delay 1 
     do JavaScript "document.getElementById('email').select();" in document 1 
     delay 1 
     do JavaScript "document.getElementById('email').value = '" & email & "';" in document 1 
     delay 1 
     tell application "System Events" 
      keystroke space 
     end tell 
end tell 
関連する問題