Automation running on a locked machine



  • I am fairly new to the automation scene and am looking for some advice. I've done Selenium development for about 2 years however, I just got a new job. Coming from a Selenium background, when running Selenium based tests I was able to run it on a VM or lock the machine without messing with the tests.

    I am now working where I'm needing to test the OS and desktop applications. The framework they have decided to use is Pywinauto (python controlling desktop or application elements) as that's what they found easiest to use. One task that's been given to me is the necessity to run the automated tests on a locked machine.

    Pywinauto has some documentation on running tests on a locked machine but not much (located here). I have attempted to do several of the things listed there, such as utilizing the windows task scheduler to run the executable, changing the way the "send_keys" function is utilized, and using a batch file to run the script. I've also done some research into creating a windows service that can host the script. However, either I have gone about these in the wrong way or nothing has seemed to work fully for my desired use case.

    There are a few requirements on the machine that I need to follow. The machine that I am testing, does not have an internet connection and therefore I can't remote into it to run the test. For security reasons, the machine can't be left unlocked while the tests are run. I'm also extremly limited on what I can install (currently, they compile the python code into an executable and run it on the system).

    The two main questions that I have are:

    1. Is there a way to run python scripts (somewhat GUI driven) on a locked machine?
    2. Is there a testing framework that is more capable of this task that I can recommend for my team to utilize?


  • Try this code:

    for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (
      %windir%\System32\tscon.exe %%s /dest:console
    )
    

    to create a bat file and it will simulate you still log in to the system. Found it from here: https://support.smartbear.com/testcomplete/docs/testing-with/running/via-rdp/keeping-computer-unlocked.html



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2