pywinauto / pywinauto

Windows GUI Automation with Python (based on text properties)
http://pywinauto.github.io/
BSD 3-Clause "New" or "Revised" License
4.87k stars 687 forks source link

Killing child windows kills the parent window as well #738

Open verashanky opened 5 years ago

verashanky commented 5 years ago

I am working on an automation script(web), where I am trying to check if File upload window is already exist or not before I click on Browse button in my web app.

So in the code below I am getting the list of windows and killing it untill there are no more Open windows.

open_windows = pywinauto.findwindows.find_elements(title_re='Open')
if len(open_windows) >= 1:
    for window in open_windows:
        Application().connect(handle=window.handle).kill()

But this particular code is killing the parent window as well. While debugging, I can see only one open_windows and this code is able to identify that open window, however, it looks like the window.handle is same for both Open window and parent window, which causes this issue I believe.

vasily-v-ryabov commented 5 years ago

Replied in comments on StackOverflow: https://stackoverflow.com/q/56249314/3648361

Only the whole process can be killed, not a separate window. It can be closed, but not killed.