You can also watch this video at YouTube (but with ads).
Here is the sample code:
var safari = Application("Safari"); safari.includeStandardAdditions = true; var jsScript = ""; jsScript += "document.getElementsByName('firstname')[0].value ='A';"; jsScript += "document.getElementsByName('lastname')[0].value ='B';"; jsScript += "document.getElementsByName('zipcode')[0].value ='12345';"; jsScript += "document.getElementsByName('bodytext')[0].value ='This is a test.';"; jsScript += "document.forms[0].submit();"; safari.doJavaScript(jsScript, { in: safari.windows[0].currentTab });
Pretty cool! Thank you for sharing this. Something for others to keep in mind is that websites that use CAPTCHAs may cause this to not work (or work as smoothly as we may want).
A great video. Made the time I spent learning the basics of Javascript worthwhile. Probably doesn't appeal to a significant portion of your viewers but I really appreciate it. Thanks Gary.
Woah — way too geeky. All this effort to enter normal details?
all the best
Gary,
You said you could do this in either Automator or Script Editor. Would it be possible to post a script editor version? If you don't have time to fool with it I certainly understand. Thanks. Dana
Dana: The JavaScript is the same. Using Script Editor is just like using Automator when you are just including a script and no other actions.
Thanks Gary. I've tried to adapt the script to see if I could make a script using JavaScript that does the same thing that one of my more complicated AppleScripts accomplishes. I've had success with the modified code when putting the code in the JavaScript console but have not had much luck with the code when using Script Editor. I'll keep working on it. Thanks for posting the video that gave me the inspiration to try. Dana
Gary, I did get my modified code to work using Script Editor. Had to change my thinking a bit but your comment that "The JavaScript is the same" and a bit of internet searching put me on the right track. I don't think you'll make a JavaScript convert out of me just yet but this post may have taken me down that path. Thanks again for making the original post and for being there for us. I'll try to make comments only during normal business hours from now on. Dana
Gary -- would this work with a PDF file that had fill in the blanks?
EA: No. It relies on web pages being scriptable (JavaScript). PDFs are not.