[Squish for Mac] setHookSubprocesses breaks AUT
-
Hi there, maybe someone knows how to fix the hooking subprocess.
The main issue is attaching it to the subprocess. And I'm trying to resolve it.
I'm writing autotests for a plugin. The plugin's window starts as a subprocess.
I can attach Squish to any process or window (by title) on Windows, so it works well.
But for Mac, Squish does not have such functionality to attach Squish to an already existing process.In Squish IDE hooking subprocess works well on Mac. But I'm using PycCharm.
Simple code in Squish IDE:
def walk_children(parent: object, depth: int = 1000): for child in object.children(parent): yield child if depth: yield from walk_children(child, depth - 1) def main(): startApplication("SketchUp path_to_project.skp") """ Then I manually start the plugin (just because I don't have handlers for now to start it in a script) And then the script below works well. Click on the button on the plugin's window worse well """ for obj in walk_children(waitForObject(names.plugin_main_window)): if obj.identifier == "My_Buttont": mouseClick(obj) pass
In Pycharm I tested two methods to start AUT:
- subprocess.Popen + attach
- squish.startApplication
Before starting any tests I set the hooking subprocess:
squishtest.setHookSubprocesses(True)So with setHookSubprocesses(True) and squish.startApplication, the plugin is not working. I can not start it. I understand it is a plugin's issue, not a squish issue, but maybe if someone knows deeply how the hooking works, I will resolve the issue from my side because devs are super busy as usual.
For other cases:
- setHookSubprocesses(False) and squish.startApplication
- setHookSubprocesses(False) and subprocess.Popen
- setHookSubprocesses(True) and subprocess.Popen
- the plugin works well, but elements and the plugin's window are not visible (LookupError)
I will be happy to see any ideas to attach to Squish to the existing process/window
-
@squisher, one can inject the Squish for Mac support into a running application (may require removing or adjusting the Hardened Runtime, if set for the application), via...
squish_for_mac_dir/examples/mac/injection/injectMacWrapper.py
It requires XCode to be installed on that computer.
Usage:
injectMacWrapper.py [--squish-dir=the_dir] --port=the_port aut_name_without_.app_postfix
aut_name_without_.app_postfix
can be an absolute or relative path to an app bundle. The app must already be running.Example (which explicitly launches SquishAddressBook.app beforehand):
cd "/Users/myuser/Squish for Mac/examples/mac/injection" open ../addressbook/SquishAddressBook.app ./injectMacWrapper.py --port=4444 ../addressbook/SquishAddressBook
The
--squish-dir
option has be left out; injectMacWrapper.py cycles through the parent directory, trying to find the Squish installation folder. This will not work when moving the .py file out of the Squish folder.Best regards,
Clemens Anhuth -