• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
checking GUI action status
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

checking GUI action status


  • Subject: checking GUI action status
  • From: Jim Brandt <email@hidden>
  • Date: Wed, 7 Jul 2010 10:21:29 -0500

Is there a way to check if an action performed via GUI scripting completed correctly in a web browser?


Here's my problem.

I have a script that I use to retrieve information on a daily basis from the Fidelity website.

This script runs automatically every weekday at 7:00 pm via CRON. Because of the complexity of this script, I'm not going to post it... it's long.

In general terms, here are the steps:
1) The script logs into my account on Fidelity
2) picks a page to view
3) sets Page Setup to landscape print
4) clicks a link on the page that formats the page for printing
5) prints that page, picking "Preview" as the print option
6) switches to the Preview application
7) saves the file in a designated name, which includes the date
8) closes Preview
9) logs off Fidelity

This script has been working for a couple years. I occasionally have to tweak it because Fidelity changes their pages such that the links on their page change names and/or element numbers. (A large portion of the navigation of the Fidelity page is done via GUI scripting). 

Yesterday, step 4 failed to open a new page, and the script from that point down acted on the wrong pages.

Running the script manually, the code executes without error but the page fails to open.

Clicking the link manually, a new window opens as expected.

I have looked at the link using UI Browser 1.4.1. It hasn't changed recently. The script doesn't stop with an error as it would if the link didn't exist, it just doesn't open the new page.

Here's the snippet of code that represent steps 2 thru 5

set the current_time to the time string of the (current date)
set mess to current_time & " - Moving to Portfolio page"
tell me to My_Lib's Message(mess, logfile) -- log it

tell application "System Events"
tell process "Safari"
set nm to name of front window
click UI element "Portfolio Positions" of UI element 1 of scroll area 1 of group 3 of window nm


delay 2
--------------- check if page has loaded ---------------
My_Lib's check_Safari_page_loaded(30)


click menu item "Page Setup…" of menu 1 of menu bar item "File" of menu bar 1
delay 2


set the current_time to the time string of the (current date)
set mess to current_time & " - Changing page setup to landscape"
tell me to My_Lib's Message(mess, logfile) -- log it


-- landscape mode
set {x, y} to position of sheet 1 of front window
set {x, y} to {x + 202 + 19, y + 165 + 19}
click at {x, y}
keystroke return
delay 1


set the current_time to the time string of the (current date)
set mess to current_time & " - Format for Printing"
tell me to My_Lib's Message(mess, logfile) -- log it
set nm to name of front window

click UI element "Format for printing in new window" of UI element 1 of scroll area 1 of group 3 of window nm


delay 1
--------------- check if page has loaded ---------------
My_Lib's check_Safari_page_loaded(30)
delay 1
set nm to name of front window


keystroke "p" using command down
-- button 2 = Print
-- button 3 = Cancel
-- button 4 = Preview
set trys to 0
repeat until (exists sheet 1 of window nm) or (trys > 60)
delay 0.5
set trys to trys + 1
end repeat
if trys > 60 then
set mess to current_time & " - Print dialog not opened in 30 seconds"
tell me to My_Lib's Message(mess, logfile) -- log it 
error number -128
end if
click button 4 of UI element 4 of sheet 1 of window nm
end tell
end tell

It's the line:
click UI element "Format for printing in new window" of UI element 1 of scroll area 1 of group 3 of window nm
that has quit working.

I changed it to:
click UI element 2 of UI element 1 of scroll area 1 of group 3 of window nm
but the results are the same... no error but no action either.

The last time this worked was Friday. The script didn't run Monday, it failed to execute properly last night.

My question is:
is there a way to perform an action in System Events (in this case, the click UI element) and test to see if the action happens sucessfully?

Sorry for the long message. 

G4 dual PowerPC running Tiger 10.4.11, Safari 4.1
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: checking GUI action status
      • From: Bill Cheeseman <email@hidden>
    • Re: checking GUI action status
      • From: Bill Cheeseman <email@hidden>
  • Prev by Date: Re: Mail.app: How can I configure replied message
  • Next by Date: Excel Pivot Table via AppleScript
  • Previous by thread: 'version' Deprecated
  • Next by thread: Re: checking GUI action status
  • Index(es):
    • Date
    • Thread