UI Element Inspector를 사용하여 애플 스크립트로 버튼을 클릭하는 방법


5

저는 애플 스크립트를 처음 사용합니다. 웹 페이지를 열고 해당 웹 페이지의 버튼을 클릭하려고합니다.

여기 내 스크립트가 있습니다 :

tell application "Safari" to activate
tell application "System Events"
    tell application "System Events" to open location "https://itunes.apple.com/us/app/ibooks/id364709193?mt=8"
    click button "View In iTunes" of window "iBooks for iPhone, iPod touch, and iPad on the iTunes App Store"
end tell

여기 내 정보는 인스펙터에서 수집 한 것입니다.

<AXApplication: “Safari>
 <AXWindow: “iBooks for iPhone, iPod touch, and iPad on the iTunes App Store>
  <AXGroup>
   <AXGroup>
    <AXGroup>
     <AXScrollArea: “”>
      <AXWebArea: “”>
       <AXLink: “View In iTunes>
        <AXGroup: “”>

Attributes:
   AXRole:  “AXGroup”
   AXSubrole:  “(null)”
   AXRoleDescription:  “group”
   AXChildren:  “<array of size 1>”
   AXHelp:  “”
   AXParent:  “<AXLink: “View In iTunes>”
   AXPosition:  “x=-9566 y=574”
   AXSize:  “w=10105 h=23”
   AXTitle:  “”
   AXDescription:  “”
   AXValue:  “”
   AXFocused:  “0”
   AXEnabled:  “1”
   AXWindow:  “<AXWindow: “iBooks for iPhone, iPod touch, and iPad on the iTunes App Store>”
   AXSelectedTextMarkerRange (W):  “(null)”
   AXStartTextMarker:  “<AXTextMarker 0x100151f70 [0x7fff77fa1110]>{length = 24, bytes = 0x070000000000000078140319010000000000000001000000}”
   AXEndTextMarker:  “<AXTextMarker 0x100177c50 [0x7fff77fa1110]>{length = 24, bytes = 0x9a00000000000000c09de015010000000e00000001000000}”
   AXVisited:  “0”
   AXLinkedUIElements:  “(null)”
   AXSelected:  “0”
   AXBlockQuoteLevel:  “0”
   AXTopLevelUIElement:  “<AXWindow: “iBooks for iPhone, iPod touch, and iPad on the iTunes App Store>”
   AXTitleUIElement:  “(null)”

Actions:
   AXPress - press
   AXShowMenu - show menu

"iTunes에서보기"버튼을 클릭하려면 어떻게합니까?


답변:


3

가장 쉬운 방법입니다 ...

tell application "Safari"
    if not (exists document 1) then reopen
    activate
    set URL of document 1 to "https://itunes.apple.com/us/app/ibooks/id364709193"
    delay 3
    do JavaScript "document.getElementsByClassName('lockup product application')[0].childNodes[3].onclick()" in document 1
end tell
당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.