3

I am looking at automation tools and have found pywinauto easy to use and therefore have decided to seek using it as my framework. I have one issue that I've attempted to work through but possibly just need help or a clear answer at this point.

I must follow the following conditions on my SUT:

  1. I the systems I am running cannot be connected to the internet (so remoting into the SUT is out of the question).
  2. Because of the sheer amount of automated tests that I will have, I cannot just leave the machine unlocked and unattended to run the tests (for example, running them overnight). This should be obvious for security reasons.
  3. I also cannot install anything new on the SUT. I'm creating the tests on a separate system and creating an executable to run on the SUT.

I couldn't seem to find anywhere that specifically talks about lock screen execution other than here in the pywinauto documentation. I haven't seen anyone online that has used these methods however.

I've attempted to do something similar to what is below:

    from pywinauto import Desktop, Application
    from pywinauto import Application
    import time

    try:
        time.sleep(30)
        #Here I lock the machine manually (for testing purposes)
        app = Application(backend="win32")
        app.start("explorer.exe")
        print("1. Opened Explorer\r\n")
        app["File Explorer"].wait('ready', timeout=10)
        print("2. Ready check completed\r\n")
        app["File Explorer"].child_window(title="Desktop (Pinned)", control_type="ListItem").send_keystrokes("{ENTER}")
        print("3. Opened the Desktop item\r\n")
        app["Desktop"].child_window(title="My Folder", control_type="ListItem").send_keystrokes("{ENTER}")
        print("4. Opened My Folder\r\n")
        app["My Folder"].child_window(title="Results", control_type="ListItem").send_keystrokes("{ENTER}")
        print("5. Opened the Results folder\r\n")

        element = app["Results"].child_window(title="Foo_Bar.test", control_type="ListItem").exists()

        if element:
            print("Yay, we executed the whole thing while locked!")

        app["Results"].send_keystrokes("%{F4}")
        app["Results"].wait_not('exists', timeout=10)
    except:
        print("FAILED, MISERABLY FAILED!!!!!")

Any help and/or feedback would be greatly appreciated.

jkwhite
  • 320
  • 2
  • 10

0 Answers0