Tuesday, April 13, 2021

#1 2020-03-15 04:52:05 pm

JRae
Member
Registered: 2020-03-14
Posts: 2

Sefari can not click UI element

I am trying to download some stock prices from a website. https://www.dukascopy.com/trading-tools … _data_feed

If you select an instrument, such as "TSLA", and login. I can successfully tell the Automator to click each button.

However, after opening up the "Date:", I cannot select a new day (doWithTimeout2). It comes back with Syntax Error

Can not click static text 1 of UI Element 5 of row 6 of table 1 of table 1 of group 12 of UI Element 1 of scroll area 1 of group 1 of UI Element 1 of scroll area 1 of group 9 of UI Element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window "Historical Data Export" of application process "Safari"



Any ideas how I can get it to select a different day?

Applescript:

on run {input, parameters}
   set CURRENTDATE to "2020-03-15"
   set ErrorCount to 0
   -- Click the "date" button.
   delay 0.1
   set timeoutSeconds to 2.0
   set uiScript to "click UI Element \"" & CURRENTDATE & "\" of group 8 of UI Element 1 of scroll area 1 of group 1 of UI Element 1 of scroll area 1 of group 9 of UI Element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window \"Historical Data Export\" of application process \"Safari\""
   my doWithTimeout(uiScript, timeoutSeconds, CURRENTDATE)
   -- Click the text “28”
   delay 0.1
   set uiScript2 to "click static text 1 of UI Element 6 of row 4 of table 1 of table 1 of group 12 of UI Element 1 of scroll area 1 of group 1 of UI Element 1 of scroll area 1 of group 9 of UI Element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window \"Historical Data Export\" of application process \"Safari\""
   my doWithTimeout2(uiScript2, timeoutSeconds)
   return input
end run

on doWithTimeout(uiScript, timeoutSeconds, CURRENTDATE)
   set endDate to (current date) + timeoutSeconds
   set endDate2 to (current date) + timeoutSeconds / 2
   repeat
       try
           run script "tell application \"System Events\"
"
& uiScript & "
end tell"

           exit repeat
       on error
           if ((current date) > endDate) then
               error "Can not " & uiScript
           else if ((current date) > endDate2) then
               set uiScript to "click UI Element \"" & CURRENTDATE & "\" of group 7 of UI Element 1 of scroll area 1 of group 1 of UI Element 1 of scroll area 1 of group 9 of UI Element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window \"Historical Data Export\" of application process \"Safari\""
               
           end if
       end try
   end repeat
end doWithTimeout

on doWithTimeout2(uiScript2, timeoutSeconds)
   set endDate to (current date) + timeoutSeconds
   set endDate2 to (current date) + timeoutSeconds / 2
   repeat
       try
           run script "tell application \"System Events\"
"
& uiScript & "
end tell"

           exit repeat
       on error errorMessage
           if ((current date) > endDate) then
               error "Can not " & uiScript
           else if ((current date) > endDate2) then
               set uiScript to "click static text 1 of UI Element 5 of row 6 of table 1 of table 1 of group 12 of UI Element 1 of scroll area 1 of group 1 of UI Element 1 of scroll area 1 of group 9 of UI Element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window \"Historical Data Export\" of application process \"Safari\""
           end if
       end try
   end repeat
end doWithTimeout2

Model: Macbook Pro
Browser: Safari 537.36
Operating System: macOS 10.14

Last edited by JRae (2020-03-15 04:55:24 pm)


Filed under: safari, Automator, click

Offline

 

#2 2020-03-15 11:02:52 pm

JRae
Member
Registered: 2020-03-14
Posts: 2

Re: Sefari can not click UI element

I found a workaround with Keystrokes but made it a little messy. And less reliable long term. So no rush, but still ken to hear ideas.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)