dysong3 Posted October 2, 2005 Posted October 2, 2005 I have a problem getting Applescript to click a button on a web page. And although it is the only button on the page I cannot use the usual option of "keystroke return" as it simply doesn't work. My script goes like this and it is the line «click button "login"» that provokes the error. The problem does not stem from the password or User ID not being correct or entered as Safari does this automatically. Any ideas on remedying this? tell application "Safari" activate make new document set URL of document 1 to "https://www.orange.ch/footer/login" end tell if page_loaded(5) then tell application "System Events" tell application process "Safari" click button "login" end tell end tell else display alert "The URL Has Not Loaded." end if on page_loaded(timeout_value) delay 2 repeat with i from 1 to the timeout_value tell application "Safari" if (do JavaScript "document.readyState" in document 1) is "complete" then return true else if i is the timeout_value then return false end if delay 1 end tell end repeat end page_loaded
dysong3 Posted October 2, 2005 Author Posted October 2, 2005 I finally found a solution to all this. It isn't very elegant but at least it works. I realised this if you hit the tab key 16 times once the page had opened, the login button finally becomes operational. You only need then hit the return to login. So here's my script tell application "Safari" activate make new document set URL of document 1 to "https://www.orange.ch/footer/login" end tell if page_loaded(5) then tell application "System Events" tell application process "Safari" keystroke tab keystroke tab keystroke tab keystroke tab keystroke tab keystroke tab keystroke tab keystroke tab keystroke tab keystroke tab keystroke tab keystroke tab keystroke tab keystroke tab keystroke tab keystroke tab keystroke return end tell end tell else display alert "The URL Has Not Loaded." end if on page_loaded(timeout_value) delay 2 tell application "Safari" repeat with i from 1 to the timeout_value if (do JavaScript "document.readyState" in document 1) is "complete" then return true delay 1 end repeat end tell return false end page_loaded
Zero Tolerence Posted October 3, 2005 Posted October 3, 2005 Doesn't it make more sence to go directly to the page where the login button directs you to?
Recommended Posts
This topic is 6993 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now