Overview¶
This examples shows how to bring a NSWindow to the foreground by using the Cocoa toolkit API from the test script:
Python example:
def main():
startApplication(...)
...
objName = {"title": "MyApp Window #1", "type": "NSWindow"}
waitFor("object.exists(\"%s\")" % objName, 20000)
nsw = findObject(objName)
nsw.makeKeyAndOrderFront_(nsw)
JavaScript example:
function main()
{
startApplication(...);
...
var objName = {"title": "MyApp Window #1", "type": "NSWindow"};
waitFor("object.exists(\"" + objName + "\")", 20000);
var nsw = findObject(objName);
nsw.makeKeyAndOrderFront_(nsw);
}
If the AUT window is overlapped by another window or if the AUT window is hidden the makeKeyAndOrderFront_
function won't work. Instead the activateIgnoringOtherApps_
function can be used:
JavaScript example:
function main()
{
startApplication(...);
...
NSApplication.sharedApplication().activateIgnoringOtherApps_(true);
}
Please note that the activateIgnoringOtherApps_
function won't work if the AUT has been minimized to the Dock.
Related information¶
API documentation for NSWindow
API documentation for NSWindow.makeKeyAndOrderFront()
API documentation for NSApplication.activateIgnoringOtherApps