I use "WinAppDriver" on Windows 10 to automate button click using "Appium.WebDriver" NuGet package.
To find an element by it's "Id" or "Name", it takes more time (around 5 seconds initially) and the problem gets worse when WinAppDriver runs continuously for more than 30 minutes or 1 hour.
To avoid performance hit, instead of using "app", "root", I use "appTopLevelWindow", "topLevelWindowHandle" as shown below.
- Appium WindowsDriver object initialization:
var topLevelWindowHandle = applicationWindow.GetAttribute("NativeWindowHandle");
topLevelWindowHandle = int.Parse(topLevelWindowHandle).ToString("X");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability("deviceName", "WindowsPC");
capabilities.SetCapability("appTopLevelWindow", topLevelWindowHandle);
windowsDriver = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), capabilities);
- Performing button click:
if(windowsDriver != null)
{
testInformationDialog = windowsDriver.FindElementsByName("Test Information");
ReadOnlyCollection<WindowsElement> okButton = null;
//If test information dialog is present, get the ok button and click it
if(testInformationDialog.Count != 0)
{
okButton = windowsDriver.FindElementsByAccessibilityId("210");
if(okButton.Count != 0)
{
okButton.First().Click();
Thread.Sleep(3000);
}
}
}
Initially WinAppDriver takes around 5 secs to click the button. While continuously running and clicking the button for every ~5 secs, the time taken to detect the button gets increased. After around 1 hour, to find the same button, it takes 10 secs and the time taken keeps increasing linearly with running time of WinAppDriver. I want to get rid of this time delay. Please help.