Access Iframe with Applescript

Hi,

Does anyone know how to access an iframe to click a link with in it using Applescript+safari?

Thanks & Regards,

MM

It may not be what you are looking for… But I’ve done this via work around:

you will need to adjust the keystrokes to navigate the page. To get the keystrokes I needed, I opened the page, and, using the keyboard only, wrote down the keystrokes.

For example, to open the https://login.yahoo.com/,

I monitored that I would need to:

  • open the location
  • keystroke my login id
  • keystroke tab
  • keystroke password
  • keystroke tab
  • keystroke tab
  • keystroke return

This got me logged in.




property thistext : ""
property theResultsString : "" --Clears out last result
tell me to beep 3
tell application "Safari"
	activate
	delay 6
	say "Opening Safari Location"
	open location "http://www.yoursitepage.com" -- opens Safari to the page
	tell application "System Events"
		tell process "Safari"
			delay 8              --to allow the page to load (8 seconds may be high for this)
			keystroke tab    -- you will need to adjust the keystrokes to navigate the page. 
			keystroke "00000"
			keystroke tab
			keystroke "00000"
			keystroke tab
			keystroke return
			
		end tell
	end tell
	delay 6


-- the rest of this is if you want to grab specific text from the resulting page. 


	tell application "Safari"
		
		
		set thistext to text of front document --this will copy the entire text of the frontmost page
	end tell
	delay 3
	tell application "Safari" to close every window
	tell application "System Events" to keystroke return
	tell application "Safari" to quit
	tell application "System Events" to keystroke return
	
	-- This will parse the data for text. You will need to know the line number of the text to grab. 
	try
		set theResultsString to paragraph 14 of thistext 
tell finder to activate
            
   display dialog theResultString
	end try