My automation Framework consists of the following: UFT developer V15.0 (previously LeanFT) + Java + Maven + Junit.
UI Tests are executed by Jenkins on a dedicated VM (OS = Windows 10). Many of my test cases include actual keyboard press, as this is a requirement of the AUT which is a web application.
My problem is that if tests are executed while user is not actually logged in - the cases which require to focus on the browser and press the keyboard - will fail. When i use RDP to log in to the VM and minimize - tests will still fail. when I use RDP, login to the VM and keep the screen open - test will focus successfully on relevant field and will pass.
I tried to disconnect using tscon using the below script, but still no use:
for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do ( %windir%\System32\tscon.exe %%s /dest:console )
As per my understanding - the problem seems to be focus. To try and understand the source of the problem, i would like to try and get the actual active element which is currently in Focus on the OS level, just like getting the active element on browser ("document.activeElement.id"). As UFT developer is able to interact with Windows elements - is there a way to retrieve such info from the OS? Or alternatively , solution to the original problem (keeping the focus on the running browser) would be great.