2016-10-27 4 views
0

Safari에는 잘 작동하지만 Chrome에는 작동하지 않는 자바 스크립트가 포함 된 AppleScript가 있습니다.AppleScript의 JavaScript는 Safari에서는 작동하지만 Chrome에서는 작동하지 않습니다.

사파리 버전 (비 관련 부분 삭제) :

tell application "Safari" 
    activate 
     do JavaScript "document.getElementsByName('files[]')[0].click();" in document 1 
    end tell 

크롬 버전 : 애플 ScriptEditor에서

tell application "Google Chrome" 
    activate 

    tell window 1 to tell tab 1 

     execute javascript "document.getElementsByName('files[]')[0].click();" 

    end tell 

크롬 버전 반환 "없는 가치".

내가 일을 명령 자바 스크립트 다른 얻을 수있는 적절한 웹 페이지에 (이 두 배 함께 할 수있는 뭔가가있을 수 있습니다 생각했을 때 내가

document.getElementsByName('files[]')[0].click(); 

또는 크롬 콘솔에서

document.getElementsByName("files[]")[0].click();" 

를 얻을 수 있습니다 따옴표 - 아직도 내가 생각할 수 있었다).

<h3>Add new documents for this patient 
     <!-- The fileinput-button span is used to style the file input field as button --> 
     <span class="btn fileinput-button" style="float: right !important;"> 
      <span>Select Files to Upload</span> 
      <input type="file" name="files[]" multiple=""> 
     </span> 
    </h3> 

어떤 아이디어 : 여기

문제가되는 요소이다? 나는 이렇게 많은 반복을 시도했다.

document.getElementsByClassName('btn fileinput-button')[0].children[1].click(); 

콘솔에서 작동하지만 AppleScript에서는 작동하지 않습니다.

내가 ...이 사이트 다양한 문제가되지 않습니다 그래서이 로그온 페이지에 "클릭"얻을 수있는

tell window 1 to tell tab 1 

      execute javascript "document.getElementById('username').value='someLoser';" 
      execute javascript "document.getElementById('password').value='YouWish'" 
      execute javascript "document.getElementsByClassName('btn btn-md btn-primary')[0].click();" 

     end tell 
:

추가 정보 ... 나에게 애플 스크립트 불확실성처럼 보이지만

은 AppleScript에 잘 작동합니다.

감사합니다.

답변

0

브라우저가 click 이벤트를 원격으로 실행하지 못하게하는 보안 문제와 관련 있다고 생각합니다. 빠른 설정으로 콘솔에서 jQuery와 바닐라를 클릭 할 수 있었지만 AppleScript에서 실행할 수 없었습니다. 나는 아무 실수도없고 단지 아무것도 아니다.

:

나는 다른 질문에서 유사한 여러 시나리오를 발견

관련 문제