I am writing an application that gathers information from the user and then fills it out on a webpage. I have no problems getting data into all of the required fields except for the pop up buttons.
The website is: http://www.its.uncc.edu/network/hostdb.html
With the code below, I can click the pop up button and the menu will appear but I keep running into problems getting it to select the menu item.
activate application "Safari"
tell application "System Events"
tell process "Safari"
-- GUI Scripting statements:
tell pop up button 1 of group 61 of UI element 1 of scroll area 1 of group 2 of window "ITS - Network Services - Faculty/Staff Computer & Printer Registration Form"
click menu item 1 of menu 1
The error is:
System Events got an error: Can’t get menu 1 of pop up button 1 of group 61 of UI element 1 of scroll area 1 of group 2 of window “ITS - Network Services - Faculty/Staff Computer & Printer Registration Form” of process “Safari”. Invalid index.
I know there is a menu somewhere, but I cannot seem to find it. I’m sure that someone on this site will have an answer because I have found so many solutions here before. Thanks in advance!
Did you ever solve this? I am having the same problem. As a workaround, I can use keystrokes to select the pop-up item I want, but there must be a better way. (mustn’t there?)
then in apple script write:
tell application "Safari"
set theWord to "hello"
set doc to document "ITS - Network Services - Faculty/Staff Computer & Printer Registration Form" -- This is the title of the webpage
log (doc's name)
This is for a text field. However, you can do index scripting for popup buttons. If you would like, I can post some examples of that.
Ah well. keystroke’s actually working fine, other than the odd fact that sending a CR (ASCII character 13) seems to hang up Safari for 5-6 seconds. Weird.