How do you iterate through menus in AppleScript? - loops

Specifically, when I'm debugging web stuff in iOS, I can start Safari Web Inspectors by clicking on the following menu items in the Safari menu bar:
Develop->iPad Simulator->Safari->my web page's title
Develop->iPad Name(mine is called Summer)->Safari->my web page's title
I'd like to iterate over the Safari menus and activate any items in the Develop menu that contain a common substring I use in my web page titles.

Here's an example. Suppose I want to click the "Show Web Inspector" menu item under the "Develop" menu in Safari. I will first get all of the UIElements in the Develop menu, then iterate over them looking for the UIElement with the proper name. Once found I can click it.
Note that the secret to this is getting the "entire contents" of some UIElement, in this case the Develop menu. That gives me a list of every UIElement in the menu so that I can iterate through them and find whatever I want.
Also note that I have a try block around the if statement. That's because some UIElements don't have a name and it errors, so this just ignores those errors.
tell application "Safari" to activate
tell application "System Events"
tell process "Safari"
set developMenu to menu bar item "Develop" of menu bar 1
set allUIElements to entire contents of developMenu
repeat with anElement in allUIElements
try
if name of anElement is "Show Web Inspector" then
click anElement
exit repeat
end if
end try
end repeat
end tell
end tell

tell application "System Events" to tell process "Finder"
set frontmost to true
tell menu 1 of menu item "Arrange by" of menu 1 of menu bar item "View" of menu bar 1
click (menu items where its name contains "a")
end tell
end tell
tell application "System Events" to tell process "Finder"
set frontmost to true
repeat with m in (get menu 1 of menu items of menu 1 of menu bar item "View" of menu bar 1)
set m to contents of m
if m is not missing value then
click (menu items of m where name contains "a")
end if
end repeat
end tell

Related

how to create dynamic menu in extjs3?

I have Ex. 10 menu in menu header and each of this has permission base so if user have permission for particular menu then that menu will be show for that user only in menu header.
If particular user have all menu(ex...10) permission so in that case application menu header part have not sufficient width so i want like after 5 menu, more menu/button kind of thing show and 6-10 menus are appearing in that more menu/button.
After I Appling all 10 menu permission to particular user, then when I remove 1 menu permission from 1 to 5 at that time 6th menu come out from the more menu and display in menu header and if I again give permission for that remove menu then 6th menu remove from the header and put it into more menu/button.
Assuming you need the 6-10 menu to overflow to to a menu:
just set enableOverflow:true on the toolbar the menus (or splitbuttons) are located in... this works for any amount of toolbar items, not just menus
https://fiddle.sencha.com/#view/editor&fiddle/3a3t

Drupal 7 – not able to change path in "edit menu link"

I am building a navigation menu in drupal 7 and in a few of the menu links it is not possible to edit the "path" in the page "Edit menu links" (under Structure -> Menu -> Navigation). Instead there is a fixed path to for ex. "Add new basic page".
These links also have the option "reset" in stead of "delete"... under Structure -> Menus.
I realize that I must have brought this problem on myself, but I am stuck and cannot figure out how to change the path for these menu links.
So I would like to change the "path". Can someone point me in the right direction?
Just turn off the menu item and create a new one which will fit your need.
This particular menu item was probably created using views. Go into the view and modify the menu item for the related view under Page settings

Selenium click absolute element out of view

i have an selenium test for an Primefaces Website
I want to select a item in a combobox
when i click the combobox with selenium it creates an absolute positioned list, where i want to click an item.
But the list is positioned absolute out of the screen (because the combobox is scrollen on the bottom of the screen)
now i want to click an item
driver.findElement(element).click();
but the click gets an timeout
org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with
when moving the item into view with firefox (hit F12, locate element, change top-css-value to 0) the test continues correctly
any idea how to click such an element?
ok found a working solution
((JavascriptExecutor) driver).executeScript("arguments[0].click();", driver.findElement(element));

Celerity - Help with popup_browser select list that updates div text on main browser

I'm screen scraping a page that includes a link that spawns a popup window that is comprised of a select list and a button to execute your selection. The objective is to click the link on the main page, make a selection on the pop-up window, click the link to confirm the selection and then view the new selection on the main webpage.
Here are the steps that I'm taking in Celerity and the results:
popup_browser = browser.image(:alt, 'Holidays').click_and_attach
#this creates a new browser to deal with the popup window
popup_browser.select_list(:id, 'ddlSlot1').select_value('Christmas')
#Selecting Christmas from the select list
popup_browser.link(:id, 'btnChangeHoliday').click
#Confirms/Implements selection
popup_browser.close
#Closes popup browser
puts browser.div(:id, 'HolidayName').text
#Here I try to print the updated holiday but nothing is printed (no text value)
Everything seems to work fine except for the last line. I've done some debugging and have confirmed that my selection has been made. It seems that the main webpage is not being updated after I click the ChangeHoliday button on the popup page.
Any thoughts or suggestions would be appreciated.
Thanks in advance for you help.
This turned out to be an easy fix. The only change required for the script to work is to add the resynchronize option to the browser initialization. After doing so the script works as expected.
browser = Celerity::IE.new(:resynchronize => true)

WPF window focus

I have an application (say App1). It has a datagrid that holds data items. If I right mouse click on a data item it brings up a "Item Details" window. However, App1 doesn't do this directly. Instead, it talks to another application, say App2, and App2 actually displays the "Item Details" window. My problem is as follows:
1. Bring up App2 then minimize it to the task bar.
2. On App1, right mouse click a data item to bring up the "Item Details" window.
3. The "Item Details" window comes up to the front, but it doesn't have the focus (the title bar is gray). App1 still has the focus.
4. If I close the "Item Details" window and repeat Step 2 again, this time the "Item Details" window not only comes up to the front but also has the focus.
5. If I do Step 1 again, then I get the same result as in Step 3.
I also noticed that I have this problem on some computers but not on others.
I have tried various methods to get the focus on the "Item Details" window but failed. The Focus() method just returns false.
(In fact, at first the "Item Details" window wouldn't even come to the front, but I set "Topmost" to true when the window is initialized and set it back to false after the contents are rendered, which forces the window to the front.)
I Suppose. Why do you need to set TopMost? Instead you should set App2's owner as App1.
HTH
Can't set App1 as App2's owner. They are unrelated applications. The only way App1 can communicate with App2 is by Windows messages. I tried to set App2 as "Item Details" window's owner but it didn't solve the problem.
Found solution to this problem. App1 has to call AllowSetForegroundWindow(...) to enable App2 to set foreground window. See MSDN documentation on AllowSetForegroundWindow.

Resources