问题
I'm trying to click on button "Free" to download application in iTunes. I'm using Javascript for Automation to open iTunes application page:
itunes = Application('iTunes');
itunes.activate();
console.log( itunes.name() );
console.log( itunes.version() );
delay(1)
appUrl = "itms://itunes.apple.com/us/app/ibooks/id364709193?mt=8";
win = itunes.openLocation(appUrl);
The script opens iBook page. How to find and click button "Free"? How to list all elements on open page?
Thank you for any help.
回答1:
After looking in the script editor, the library for the Itunes Application, i didn't found any method or object dealing with books in the itunes store. So i think, it's a dead end. The iBooks application is not scriptable anyway.
However to go ahead with your problem, clicking the [Free] button :
appUrl = "itms://itunes.apple.com/WebObjects/MZStore.woa/wa/viewTop?genreId=38&popId=42";
win = itunes.openLocation(appUrl);
The URL targeted by the [Free] button could be found by browsing books in iTunes, in the right side of the interface ( "Free books", right-clic => Copy the link ). Perhaps the URL is different for your US version but you got the idea.
来源:https://stackoverflow.com/questions/26711618/os-x-yosemite-javascript-for-automation-and-itunes