MUS
MUS

Reputation: 9

Pywinauto with self hosted runner from Github cant find the desktop windows app after login

I am using pywinauto with github self hosted runner in order to test a desktop app. Yesterday this code worked properly, but then I restart my computer and now cant see the window after login. The test case is in robot and runs fine locally. The issue is while a run the script on github and starts the self hosted runner on my machine. The line "tickblaze_window = Desktop(backend="uia").window(title_re="Tickblaze x64")" is not running properly given that the window after login is not appearing...

def open_tickblaze(app_path):
    app = Application(backend="uia").start(app_path)
    for _ in range(12):  # Try for a total of 60 seconds (12 * 5 seconds)
        try:
            app.connect(title="")  # name
            break
        except Exception as e:
            print(f"Attempt to connect failed: {e}")
            time.sleep(5)
    logs = app.top_window().print_control_identifiers()
    return app, logs

def login_tickblaze(app, user, password):
    time.sleep(5)
    login_window = app.window(class_name="Window")
    email_field = login_window.child_window(class_name="TextBox")  
    email_field.click_input() 
    email_field.type_keys("^a{BACKSPACE}", with_spaces=True)
    email_field.type_keys(user, with_spaces=True)

    password_field = login_window.child_window(auto_id="_password", class_name="PasswordBox") 
    password_field.click_input() 
    password_field.type_keys("^a{BACKSPACE}", with_spaces=True)
    password_field.type_keys(password, with_spaces=True) 
    
    login_button = login_window.child_window(title="Log In", class_name="Button")
    login_button.click_input()
    
    
    handles = handle_popups("^(Warning|Error)$", timeout=10)
    if handles:
        for hwnd in handles:
            app = Application(backend="uia").connect(handle=hwnd)
            popup = app.window(handle=hwnd)
            popup.close()

    try:
        handles = handle_popups("^(Warning|Error)$", timeout=10)
        if handles:
                for hwnd in handles:
                    app = Application(backend="uia").connect(handle=hwnd)
                    popup = app.window(handle=hwnd)
                    popup.close()

    except:
            pass
    else:
        try:
                update_button = login_window.child_window(title="Update", class_name="Button")
                
                assert update_button.wait('visible', timeout=20), "Update button did not become visible."
                update_button.click_input()
                ok_button = login_window.child_window(title="Ok", class_name="Button")
                
                assert ok_button.wait('visible', timeout=10) , "Ok button did not become visible."
                ok_button.click_input()

                try:
                    handles = handle_popups("^(Warning|Error)$", timeout=10)
                    if handles:
                        for hwnd in handles:
                            app = Application(backend="uia").connect(handle=hwnd)
                            popup = app.window(handle=hwnd)
                            popup.close()
                except:
                        pass
        except:
                pass
    try:
        tickblaze_window = Desktop(backend="uia").window(title_re="Tickblaze x64")
        tickblaze_window.wait('ready', timeout=120)  # Esperar hasta que esté lista
    except findwindows.ElementNotFoundError:
        raise Exception("La ventana de Tickblaze x64 no apareció en el tiempo esperado. Verifique que la aplicación se haya iniciado correctamente.")
    return login_window

Upvotes: 0

Views: 22

Answers (0)

Related Questions