• 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
Re: Waiting for a web page to be fully loaded
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Waiting for a web page to be fully loaded


  • Subject: Re: Waiting for a web page to be fully loaded
  • From: "Nigel Garvey" <email@hidden>
  • Date: Fri, 23 Apr 2010 09:08:44 +0100

Victor wrote on Wed, 21 Apr 2010 17:04:54 +0200:

>Within a web page in Safari a service I built with automator simply running
>an AS needs to input some keystroke only when each page is fully loaded.
>In the example below after clicking "F24" AS should wait for the complete
>loading of the new page.
>For that reason I'm trying to use the code below which resort (taken from
>somewhere in the internet) to the "do javascript" command. To no avail. I
>mean that the code runs but invariably passes the test  of the repeat line
>without looping thru the "delay 1" line even though the web page is still
>being loaded.
>What's wrong with it?

The script won't wait for Safari to react to the initial clicks, so the
repeat exit test is probably happening shortly _before_ the new page
begins to load. A short delay in a 'while' repeat immediately before
that should do the trick.

>	on run {}
>
>	tell application "System Events"
>		tell process "Safari"
>			tell UI element 2 of row 1 of table 1 of UI element 1 ¬
>				of scroll area 2 of UI element 1 of scroll area 2 of UI element 1 of
>scroll area 1 of group 3 of window 1
>				click UI element "Pagamenti"
>				delay 0.5
>				click UI element "Imposte e tributi"
>				delay 0.5
>				click UI element "F24"

      end tell
    end tell
  end tell

>			tell application "Safari"

  repeat while (do JavaScript "document.readyState" in document 1) is
"complete"
    delay 0.2
  end repeat

>					repeat until (do JavaScript "document.readyState" in document 1) is
>"complete"
>						delay 1
>						set N to N + 1
>						if N is 60 then -- there was a problem loading the page
>							error number -128
>						end if
>					end repeat
>				end tell

  tell application "System Events"
    tell application process "Safari"
>			perform action "AXPress" of image 1 of UI element 1 of group 6 ¬
>				of UI element 1 of scroll area 3 of UI element 1 of scroll area 2 ¬
>				of UI element 1 of scroll area 1 of group 3 of window 1
    end tell
  end tell
>end run

NG

 _______________________________________________
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: Waiting for a web page to be fully loaded
      • From: Laine Lee <email@hidden>
  • Prev by Date: Re: Adobe InDesign CS3 JPEG export range problem
  • Next by Date: Date question with weeknumber
  • Previous by thread: Waiting for a web page to be fully loaded
  • Next by thread: Re: Waiting for a web page to be fully loaded
  • Index(es):
    • Date
    • Thread