1

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?
2
  • what went wrong with the windows task scheduler direction?
    – Rsf
    Oct 11, 2019 at 7:16
  • @Rsf the task scheduler was not able to start the tasks while the machine was locked. As soon as I logged in (15 min or so after it was supposed to start), then it would start.
    – user41917
    Nov 12, 2019 at 22:44

3 Answers 3

1

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

2
1

We had a similar problem with CodedUI. It does not run on a locked machine, some frameworks are like that.

We solved it in the following way:

  • Setup an remote Windows Server (Jumphost)
  • Setup another Windows Server (Test Runner)
  • Configure the Test Runner to not lock ever, never, ever.
  • Configure the Test Runner to be only accessible from the Jumphost and or CI/CD systems (e.g. Firewall and account X special for this machine)
  • Login to the Jumphost via Remote Desktop (RDP)
  • From the Jumphost RDP to the Test Runner with account X.
  • Lock the Jumphost
  • Execute tests from the CI/CD also with account X.

Now the system is locked and the test run on the Test Runner. You might run into some trouble with starting the tests from the CI/CD, but that seems out of scope here.

These machines do not need to be on the Internet, they do need to be on your network. Although you could setup VPN on the Jumphost if you want to access it from home. We VPN into our office desktop, RDP to the Jumphost and then configure the Test Runner.

Tip: Change the backgrounds from the Test Runnner and the Jumphost to contain text which system it is, because if you keep the RDP session open on the Jumphost and you login you are on the Test Runner, but could confuse it for the Jumphost. Our Jumphost is also used for other services.

Alternativly leave it unlocked in a locked room. "Change your organisation or change your organisation" -- Martin Fowler, because getting this to work is communication and risk management, not blindly following "rules".

1
  • Thank you for this response. This is something that I never thought of and could be very possible. I will need to set it up and look at the specifics to see if this is something that can work for us.
    – user41917
    Nov 12, 2019 at 22:41
0

Work with your manager on the details.

"They have decided to use...". Go over the actual requirements with your manager and talk about the issue you have implementing them. What do they suggest doing?

"I'm needing to test". Who has determined this? Where are the requirements to test coming from? Who's in the loop? What conversations have been had about how to test (technically) ?

"Either I've gone about these in the wrong way or nothing has seemed to work fully". Please give details on this. Are these the details you've reviewed closely with your manager?

"There are a few requirements on the machine that I need to follow..."
So how do you do things that require an internet connection when you can't have one and pixie dust isn't included in the startup script.

Overall. More talk is needed with your manager.

3
  • 'they' is the other tester's (at my new job) that were here before I came in. At the job, they are developing the system as a whole (hardware and software) so I need to test the system as a whole (however the automated tests will only cover the software). As a new person on the team, I have been assigned this task ("Needing to test"). I've reviewed all of my finds with the testers (and other teams at the company) and they are unsure of how to proceed as well (no other similar systems/tests). Lastly, the system has no internet connection and no app needs one to run/be tested.
    – user41917
    Oct 10, 2019 at 19:11
  • Good summary. What does your manager say when you present those facts ? Oct 11, 2019 at 14:02
  • 'assigned a task' does not mean it is possible or reasonable. Further analysis to determine that is then valuable feedback for you to provide. Oct 11, 2019 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.