WinAppDriver not finding elements
See original GitHub issueHi,
I am investigating a new toolset for our automation, we were previously using white which is now deprecated and we use Selenium for our web based tests so this seems a sensible tool. However I am really struggling to get the any elements to be identified after the program launches, I’ve seen posts about desktop sessions etc but the suggested resolution there is also deprecated and I can’t find any information on the alternative.
This is the test I have it’s fairly basic just launching the app and verifying the text of the title bar of the login screen, running the steps through postman it all works fine so not really sure what’s wrong.
` public class TestQdaq { [Test] public void FindElementTest() { var driver = StartApplication(); var elementFound = driver.FindElementByAccessibilityId(“TitleBar”);
Assert.IsTrue(elementFound.Text == "Username");
//elementFound.SendKeys("9999");
driver.CloseApp();
}
public WindowsDriver<WindowsElement> StartApplication()
{
//Working code for other apps below here:
var capabilities = new AppiumOptions();
//capabilities.AddAdditionalCapability(MobileCapabilityType.App, "C:\\Program Files\\QDAQ\\QDAQ.exe");
capabilities.AddAdditionalCapability(MobileCapabilityType.App, @"C:\Program Files\ODM Mapper\ODM Mapper.exe");
capabilities.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Windows");
capabilities.AddAdditionalCapability(MobileCapabilityType.DeviceName, "NOELF-L-W10");
//Start Driver
//var driver = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723/wd/hub"), capabilities);
var _appiumLocalServer = new AppiumServiceBuilder().UsingAnyFreePort().Build();
_appiumLocalServer.Start();
var driver = new WindowsDriver<WindowsElement>(_appiumLocalServer, capabilities);
Thread.Sleep(5000);
return driver;
//Close Driver
//driver.Close();
//driver.Dispose();
}
}
}`
Appium log [info] [35m[WinAppDriver][39m [STDOUT] ========================================== [info] [35m[WinAppDriver][39m [STDOUT] POST /wd/hub/session HTTP/1.1 [info] [35m[WinAppDriver][39m [STDOUT] Accept: application/json, / [info] [35m[WinAppDriver][39m [STDOUT] Connection: close [info] [35m[WinAppDriver][39m [STDOUT] Content-Length: 131 [info] [35m[WinAppDriver][39m [STDOUT] Content-Type: application/json; charset=utf-8 [info] [35m[WinAppDriver][39m [STDOUT] Host: 127.0.0.1:4724 [info] [35m[WinAppDriver][39m [STDOUT] User-Agent: appium [info] [35m[WinAppDriver][39m [STDOUT] [info] [35m[WinAppDriver][39m [STDOUT] [info] [35m[WinAppDriver][39m [STDOUT] HTTP/1.1 200 OK [info] [35m[WinAppDriver][39m [STDOUT] Content-Length: 152 [info] [35m[WinAppDriver][39m [STDOUT] Content-Type: application/json [info] [35m[WinAppDriver][39m [STDOUT] [info] [35m[WinAppDriver][39m [STDOUT] {“sessionId”:“04A152BD-2727-4167-94E8-BB700A79EFC0”,“status”:0,“value”:{“app”:“C:\Program Files\ODM Mapper\ODM Mapper.exe”,“platformName”:“Windows”}}[info] [35m[WinAppDriver][39m [STDOUT] [info] [35m[WinAppDriver][39m [STDOUT] [info] [35m[WinAppDriver][39m [STDOUT] ========================================== [info] [35m[WinAppDriver][39m [STDOUT] POST /wd/hub/session/04A152BD-2727-4167-94E8-BB700A79EFC0/element HTTP/1.1 [info] [35m[WinAppDriver][39m [STDOUT] Accept: application/json, / [info] [35m[WinAppDriver][39m [STDOUT] Connection: close [info] [35m[WinAppDriver][39m [STDOUT] Content-Length: 47 [info] [35m[WinAppDriver][39m [STDOUT] Content-Type: application/json; charset=utf-8 [info] [35m[WinAppDriver][39m [STDOUT] Host: 127.0.0.1:4724 [info] [35m[WinAppDriver][39m [STDOUT] User-Agent: appium [info] [35m[WinAppDriver][39m [STDOUT] [info] [35m[WinAppDriver][39m [STDOUT] [info] [35m[WinAppDriver][39m [STDOUT] HTTP/1.1 404 Not Found [info] [35m[WinAppDriver][39m [STDOUT] Content-Length: 139 [info] [35m[WinAppDriver][39m [STDOUT] Content-Type: application/json [info] [35m[WinAppDriver][39m [STDOUT] [info] [35m[WinAppDriver][39m [STDOUT] {“status”:7,“value”:{“error”:“no such element”,“message”:“An element could not be located on the page using the given search parameters.”}}
Apologies for the very novice post and if it’s in the wrong place, I am following a tutorial and it’s not got any great depth to troubleshooting and my googling has returned nothing
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top GitHub Comments
Hi, It seems like you run Appium locally , can you try to connect directly to the winappdriver ? (get rid of “/wd/hub”). Also, did you manage to use that setup on other basic apps like calc ?
In your logs you should have
{"using":"accessibility id","value":"TitleBar"}
when calling “/element” but i don’t see it anywhere. (though i see Content-Length: 47 so it might have been sent)Either you have an issue in your Appium/WinAppDriver setup or the title bar you seach in your app isn’t quite what we would expect.
Unsure exactly what you are doing. (Show code or driver log for a more specific response.) You probably have windows/popups generated outside your app. You may need to make a root session to find them.