I am new to automation and I am trying to automate the WPF application using WinAppDriver with C#. I am able to load the application but getting the error like {"An element could not be located on the page using the given search parameters."} while trying to find the element with Name/AccessibilityId even after keeping the wait time.
See below:
POST /session/09551C9F-CF20-4C2B-A900-F17D2483F9D8/element HTTP/1.1
Accept: application/json, image/png
Content-Length: 45
Content-Type: application/json;charset=utf-8
Host: 127.0.0.1:4723
{"using":"accessibility id","value":"TxtPwd"}
HTTP/1.1 404 Not Found
Content-Length: 139
Content-Type: application/json
{"status":7,"value":{"error":"no such element","message":"An element could not be located on the page using the given search parameters."}}
I don't know what is happening. Any suggestions?
I did like - check for the elements and automation-id/name of element through inspect tool - set developer mode active - wait time before finding the element
var aDesiredCapabilities = new DesiredCapabilities();
aDesiredCapabilities.SetCapability("app", @"PathToApplication");
aDesiredCapabilities.SetCapability("deviceName", "Windows 10");
var aWindow = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), aDesiredCapabilities);
aWindow.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
aWindow.FindElementByAccessibilityId("TxtPwd").SendKeys("qwerty");
aWindow.FindElementByAccessibilityId("TxtUser").SendKeys("123456");
aWindow.FindElementByAccessibilityId("Clear").Click();
aWindow.FindElementByAccessibilityId("TxtPwd").SendKeys("qwerty");
aWindow.FindElementByAccessibilityId("TxtUser").SendKeys("123456");
aWindow.FindElementByAccessibilityId("Login");