Sorry for the possibly confusing title.
My problem is that I'd like to download Apple's Command Line Tools for XCode without the need to click on the single buttons. I want to use this for a faster setup of new developer workstations combined with Chef.
The script and error are as follows:
tell application "Safari"
make new document at end of every document --> document "Ohne Titel"
set URL of document 1 to "https://developer.apple.com/downloads/index.action"
get name of document 1 --> "Ohne Titel"
do JavaScript "var head= document.getElementsByTagName('head')[0];
var script= document.createElement('script');
script.type= 'text/javascript';
script.src= 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js';
head.appendChild(script);" in document 1 --> missing value
do JavaScript "alert('test')" in document 1 --> missing value
do JavaScript "document.forms['appleConnectForm']['accountname'].value = 'somename'" in document 1 --> missing value
do JavaScript "document.forms['appleConnectForm']['accountpassword'].value = 'somepassword'" in document 1 --> missing value
do JavaScript "document.appleConnectForm.submit();" in document 1 --> missing value
do JavaScript "var atags = document.getElementsByTagName('a')" in document 1 --> missing value
do JavaScript "for (var i=0; i<atags.length; i++){ if (atags.textContent=='Command Line Tools for Xcode'){ atags[i].click(); } }" in document 1 --> missing value
set name of window 1 to "Ohne Titel"
end tell
Updates to the the script and errors I am running into here: https://gist.github.com/1993352
The Javascript on line 17 is properly executed and I see an alert message. Any of the other lines is not executed as expected.
How can I get this to work and is the current Javascript not executed except for this one line?