Hello-
I think this is a fairly simple problem.
I’m trying to write a script that will perform the following:
(1) open this web page http://www.travelandleisure.com
(2) take a screenshot
(3) save screenshot to a designated folder
This is what I have so far:
property target_URL : “http://www.travelandleisure.com/”
open location target_URL
do shell script “/usr/sbin/screencapture -w page.pdf”
It nearly works, but the screenshot seems to be happening before the web page opens. As a result, the screenshot doesn’t include the web page, but the screen prior to the web page opening.
Any help on this would be greatly appreciated. Thanks in advance to whoever can help me figure this out!
You need to add a delay to your script between the ‘open’ command and the screenshot.
Depending on the browser you’re using you may be able to query the application state to wait until it’s idle, or you’ll have to estimate how long it will take and use a ‘delay’ command with the appropriate number of seconds you want to wait.
open location target_URL
delay 10 -- wait 10 seconds
do shell script "/usr/sbin/screencapture -w page.pdf"