Re: UI Scripting, Safari and text field
Re: UI Scripting, Safari and text field
- Subject: Re: UI Scripting, Safari and text field
- From: Joshua See <email@hidden>
- Date: Fri, 9 Jan 2004 08:22:11 -0600
On Thursday, January 8, 2004, at 01:21 PM, Timothy K. Wilkinson wrote:
I'm trying to use the UI Scripting to set a text field of a web page
to a
certain value.
Using PreFab's UI Browser I came up with this script:
tell application "System Events"
tell process "Safari"
set value of text field 1 of scroll area 1 of group 2 of
window "Add
new user" to "some text"
end tell
end tell
This works on the surface. It puts the text into the field on the web
page
and everything seems fine. However when you click on the field the
text
disappears. If you don't select the field but just click the submit
button
then a blank value is submitted.
What step am I missing to make that value stick in the web page?
Um, why script the GUI?
tell application "Safari"
set targetwin to some window whose name is "Add new user"
do JavaScript "document.forms[0].elements[0].value='some text';" in
targetwin
-- or document.formname.fieldname.value
end tell
Note that the first line in the tell block is "some"what whimsical, but
in real life you want to encase it in a try block in case no windows
matched, and add an if/then statement to throw an error on multiple
matches.
--
Sincerely,
Joshua See
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.