Activate window on test Agent without Remote Desktop Connection
Hello,
I have the following code for switching windows in Winappdriver because my app has a splashscreen:
var handle = AppiumDriver.CurrentWindowHandle;
while (AppiumDriver.WindowHandles.Contains(handle))
{
Thread.Sleep(1000);
}
if (AppiumDriver.WindowHandles.Count > 0)
{
AppiumDriver.SwitchTo().Window(AppiumDriver.WindowHandles[0]);
}
This code is working when I run tests on Test Agent with Remote Desktop Connection but if I run test without RDC this fails, I've entered a Thread.Sleep to wait until app is displayed.
- Does anybody know how I can switch window in this case?
- On this Test Agent how I can activate the App window so that other windows are not displayed over my App.
alinasofting Please post code that fail on Agent and WinAppDriver log. Also try to print WindowHandles to analyze and take screenshot.
Does the PC on which the test agent is running gets locked after sometime?
@anunay1 My test agent is configured as interactive, I don't know what you mean about locked,
@Shakevg I could not reproduce the behavior today but I cannot see the logs in Azure:

Sounds to me like you may not have your VMs configured for windows UI tests. You will need atleast a minimized RDC session so the VMs can inherit the GUI.
I don't know what your CI/CD pipeline is like, but for us we have a VM which acts as the host. On that we use hyper v to connect to our UI test VMs. These are then minimized on the host. They HAVE to be minimized, an active connection must be there so the GUI can be used.
You can disconnect from the host no problem, so just make sure atleast one of your VMs is dedicated as the host.
Here is an easy to read article on how to configure your host VM for minimized RDC sessions https://support.smartbear.com/testcomplete/docs/testing-with/running/via-rdp/in-minimized-window.html
You can even do this locally, and then just have that minimized while you go about your business