so I am trying to get to a list view of the calendar on this page “http://www.abccvc.com/hot_links/Calendar.aspx”, however the only way that i have been able to make this happen is to double a line of code as shown here
tell application "Safari"
open location "http://www.abccvc.com/hot_links/Calendar.aspx"
do JavaScript "javascript:__doPostBack('ctl00$ctl00$ctl00$ctl00$cphBody$cphContent$cphContent$cphContent$ctl01$lnkView','')" in document 1
delay 1
do JavaScript "javascript:__doPostBack('ctl00$ctl00$ctl00$ctl00$cphBody$cphContent$cphContent$cphContent$ctl01$lnkView','')" in document 1
delay 1
set listView to source of document 1
--set listView to do shell script ("curl -A mozilla/5.0 " & "http://www.abccvc.com/hot_links/Calendar.aspx")
end tell
i got the doPostBack from this source code
List view
I’m still brand new to this, so i’m fairly certain this is just something i haven’t learned yet, but any help would be greatly appreciated. Thanks in advance
I think it’s something to do with whether or not the javascript has finished doing its thing. This works for me:
tell application "Safari"
open location "http://www.abccvc.com/hot_links/Calendar.aspx"
do JavaScript "javascript:__doPostBack('ctl00$ctl00$ctl00$ctl00$cphBody$cphContent$cphContent$cphContent$ctl01$lnkView','')" in document 1
set listView to ""
repeat until listView is not equal to ""
set listView to source of document 1
delay 0.5
end repeat
end tell
There is a repeat loop delaying half a second each time to see if the get source part comes up with something.
The problem is that the page still remains in the calendar format rather than a list of all the events for the organization, which is a problem because i need the calendar for the whole year rather than just the current month. My script usually worked to navigate to the page I needed, however it would occasionally run into problems if the page took longer to load, so I was just wondering if there is a more effective way to do it.
Try
tell application "Safari"
open location "http://www.abccvc.com/hot_links/Calendar.aspx"
tell me to wait_for_page(1)
do JavaScript "javascript:__doPostBack('ctl00$ctl00$ctl00$ctl00$cphBody$cphContent$cphContent$cphContent$ctl01$lnkView','')" in document 1
tell me to wait_for_page(1)
set listView to source of document 1
end tell
on wait_for_page(inWindowIndex)
activate application "Safari"
tell application "System Events" to tell application process "Safari"
repeat
delay 0.5
set theStatusText to name of static text 1 of group 3 of window inWindowIndex as text
if theStatusText begins with "Contacting" or theStatusText begins with "Loading" or theStatusText begins with "Waiting" then
else
exit repeat
end if
end repeat
end tell
end wait_for_page