I am trying to understand why my Applescript does nothing when the same javascript code entered into the Safari location bar is running.
Go to the search results page, for example: http://www.google.com/search?q=test . For proper behavior, enter it in the location bar and press enter:
javascript: document.getElementsByClassName('vspib')[0].click();
You will see that he selects a magnifying glass for the first search result.
This is what I want to do through javascript. So I typed the following:
tell application "Safari" activate do JavaScript "document.getElementsByClassName('vspib')[0].click();" in document 1 end tell
However, he does nothing. Any ideas?
source share