![]() |
error seems to be coming from the get menu part
"System Events got an error: Can’t get menu 1 of pop up button 1 of group 3 of UI element 1 of scroll area 1 of UI element 1 of scroll area 2 of UI element 1 of scroll area 1 of group 3 of window . . . . " Tried the shorter script above, but it won't compile, with the error "Expected end of line but found identifier." at the web area part with area highlighted. I found that if I put in a long enough delay to select a location manually and then add in get value of pop up button 1 of group 3 of UI element 1 of scroll area 1 of UI element 1 of scroll area 2 of UI element 1 of scroll area 1 of group 3 of window "Main" of application process "Safari" It returns whichever location that I selected. I tried changing the get value to set value, but that had no effect. D |
Partial success:
I couldn't get anything to work, so I thought about a different approach. Using a loop and down arrow to scroll through all of the locations until I hit the right one. Here is the script so far set menu_item to "Honolulu" as string (* my location *) tell application "Safari" activate tell (make new document) to set URL to "https://intranet.locations/" delay 5 tell application "System Events" repeat until value of pop up button 1 of group 3 of UI element 1 of scroll area 1 of UI element 1 of scroll area 2 of UI element 1 of scroll area 1 of group 3 of window "Main" of application process "Safari" is menu_item tell application "System Events" to click pop up button 1 of group 3 of UI element 1 of scroll area 1 of UI element 1 of scroll area 2 of UI element 1 of scroll area 1 of group 3 of window "Main" of process "Safari" key code 125 (* down arrow *) keystroke return (* confirm choice of menu item *) delay 0.5 end repeat beep end tell end tell This works, albeit very slowly. For some reason, there is a long pause after the popup button is pressed (about 5 seconds) before it arrows down to the next selection even though there is no delay statement between the two actions. If you see anything I can change to clean up the code to make it faster, let me know. The next task will be getting the information that is returned in table form copied into an email - if you have any suggestions in that regard :) D |
I don't understand why you're UI scripting this when it's much easier to use Safari's Do Javascript command. write a short javascript in an applescript variable and fire it off, like the following:
Code:
Set JScode to "themenu = document.getElementById('LocationName'); |
tw,
thanks for the reply. I am not very familiar with javascript, but I did try dropping in your script, but it didn't appear to do anything. Does in need to have a dojavascript in front of it? Originally I was trying to avoid UI scripting in favor of javascript, but was not having any luck. Thanks D |
it's really hard to debug these things without access to the code. did you check console, or the safari error log (if you have it enabled) to see if it's throwing any errors?
|
ok, a little playing around, and I realized that I had the reference form wrong. try this version instead:
Code:
set JScode to "themenu = window.frames[0].document.forms[0].LocationName |
Thanks again for the reply and trying to help.
I tried your new code, with same results. The page has 2 frames, as far as I can tell, with the only form on the page being in the second frame so I did change the frames[0] to frames [1] and tried that as well. Still nothing happening after the page loads. D |
Quote:
|
If you know who developed the web page, you might try asking the programming what the elements/documents are for what you are trying to do. Ask them, how do they access this with javascript.
|
Ok, looked at Safari error log, there is this:
TypeError: Result of expression 'window.frames[1].document' [undefined] is not an object. |
well, that's not very helpful. :D what does the html of the frames page look like? not the page you posted, which is what goes in the frame, but the outer page...
|
Ok, here is the html for the main page
<html> <head> <title>Main</title> </head> <frameset rows='70,*' border='0'> <frame src='/header.asp' name='Header' marginheight='0' marginwidth='0' scrolling='no' noresize> <frame src='http://intranet.locations/' name='Report' marginheight='0' marginwidth='0' scrolling='auto'> </frameset> </html> Hope that helps d |
alright, do this. copy the following code:
Code:
set JScode to "themenu = window.frames['Report'].document.forms['locations'].LocationName |
Quote:
A property can’t go after this “"”. with "Index " highlighted when trying to compile. Won't let me run the script. D |
Quote:
|
Ok,
Thanks! It compiles now, but when run, nothing happens. Error log returns the same error: TypeError: Result of expression 'window.frames['Report'].document' [undefined] is not an object. |
well, I don't know what to tell you. I duplicated the structure of the two pages you posted and the script works fine, so that tells me that something is off in what you sent, or some kind of DOM manipulation is happening in the javascripts that I can't see. the fact that it says the document is not an object tells me that that frame is not loaded when the script runs, but not why...
if it were me, I'd start playing with Safari's Web Inspector (right click on the menu and select 'Inspect Element') to see if I could figure out the correct way to reference the menu and scripts (which is where we're stuck). nothing more I can do on this end, though (except guess), without access to the site. |
I think I may have stumbled on something, although I'm not sure if it is the problem, or if it is, if it can be worked around.
found another error that says: Unsafe JavaScript attempt to access frame with URL https://extranet.mycompany.com/web/t.../px/locations/ from frame with URL http://www.mycompany.com/px/locations/Locations.asp. Domains, protocols and ports must match. I have edited out my company name out of paranoia, and I could perhaps provide you with a url, but don't want it on the forum, for same paranoia reasons. I appreciate your help thus far, and understand if you are not interested in helping further, but if you are, let me know and I'll give you a url to test it out via email or private msg. d |
you can send me a private message with the info on the forum, no problems. just hover your mouse over my user name and click from the auto-dropdown -menu.
|
TW, sent you a private message yesterday, but can't find it in my sent messages. Did you get it?
D |
| All times are GMT -5. The time now is 05:35 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.