Closing GTK Window in dogtail GUI test

I am prototyping a GUI test for a GTK application with dogtail and I have succeeded in opening a Window as shown below

import dogail
from dogtail.tree import *
import subprocess

subprocess.Popen("acme", shell=True)
app = root.application("acme")
app.child("Acme help menu").click()
app.child("About menu item").click()  # creates About Window

## Trying to close the above Window
dogtail.rawinput.keyCombo('<Alt>F4') # does not work

How to I close or hide the About Window? The window itself has no user-created close button other than the one from on the title bar. I’d like to simulate a click on the close button on the title bar or send the sequence Atl+F4 but none of the options I’ve tried works (see above) .

I’ll happily settle for sending a GTK signal but I can’t figure out how to achieve this either.

I wonder if the title bar is the exclusive preserve of the windowing system.

dogtail.rawinput.keyCombo('<Alt>F4') did not work because I was working in WSL which does not have an X window manager.

BTW, the window to be closed grab focus before the key combo Alt+F4 is sent.

PS: for completeness though I’d like to know why this command does not work in WSL. Is it because of the absence of an X window manger as I suspect?

From what I can tell WSL2 uses Wayland as the display server (a fork of Weston, I believe). See [query] Support for Wayland? (#3) · Issues · dogtail / dogtail · GitLab for more informations regarding dogtail usage on pure Wayland.

However it’s also possible to setup XOrg on WSL2: Using WSL 2 with X-Server — Linux on Windows | by Rafael Faita | Javarevisited | Medium

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.