I am trying to get a list of all the windows on the desktop with the code below. However, I get zero results... should this work?
var desktopCapabilities = new DesiredCapabilities();
desktopCapabilities.SetCapability("app", "Root");
desktopCapabilities.SetCapability("platformName", "Windows");
desktopCapabilities.SetCapability("deviceName", "WindowsPC");
using (var desktopDriver = new WindowsDriver<WindowsElement>(WindowsDriverUri, desktopCapabilities))
{
var windows = desktopDriver.FindElementsByTagName("Window"); // returns zero results
}
I tried the following, it didn't return zero. But, it returned the wrong value.
var windows = desktopDriver.FindElementsByClassName("Window");
Hi @mdesousa,
Would you please retry your scenario using WinAppDriver v1.1.1 release?
It appears to work with v1.1.1... thanks! FYI, I noticed in the WinAppDriver console a number of exception warnings... the resultset still looked ok, don't know if those exceptions are concerning. See the output below... the "Exception" section (including the "Ignoring new object and keeping existing one" message) was repeated many times (more than 20?). It appears to display one entry for each email that I had opened in Outlook... I've obfuscated and left a single entry for illustration, but you can probably reproduce if you make this call while Outlook is open.
==========================================
POST /session/C36B34B7-9BEE-436A-9D02-E5E24BA05EEC/elements HTTP/1.1
Accept: application/json, image/png
Content-Length: 37
Content-Type: application/json;charset=utf-8
Host: 127.0.0.1:4723
{"using":"tag name","value":"Window"}
Exception: Encountered element sharing the same runtimeId 42.6490686.3.-2
new Object {[OBFUSCATED], FromField, 42.6490686.3.-2}
runtimeId 42.6490686.3.-2
className FromField
name [OBFUSCATED]
NativeWindowHandle 0
existing Object {[OBFUSCATED], FromField, 42.6490686.3.-2}
runtimeId 42.6490686.3.-2
className FromField
name [OBFUSCATED]
NativeWindowHandle 0
Ignoring new object and keeping existing one
HTTP/1.1 200 OK
Content-Length: 325
Content-Type: application/json
{"sessionId":"C36B34B7-9BEE-436A-9D02-E5E24BA05EEC","status":0,"value":[{"ELEMENT":"42.9836860"},{"ELEMENT":"42.793194"},{"ELEMENT":"42.12387662"},{"ELEMENT":"42.23466224"},{"ELEMENT":"42.6624114"},{"ELEMENT":"42.15603540"},{"ELEMENT":"42.14948448"},{"ELEMENT":"42.5576022"},{"ELEMENT":"42.18091894"},{"ELEMENT":"42.66734"}]}
==========================================
Hi @mdesousa,
Thanks for the update. I'm glad it works out very well for you. Yes there is an issue with one of the Outlook release where some distinct elements sharing the same runtimeId. They are aware of this and are working on a fix. These exceptions are merely warnings to help application developer identify the elements that share the runtimeId.
Having said that, as long as the warning messages doesn't come from your application, it shouldn't be a concern.
Most helpful comment
It appears to work with v1.1.1... thanks! FYI, I noticed in the WinAppDriver console a number of exception warnings... the resultset still looked ok, don't know if those exceptions are concerning. See the output below... the "Exception" section (including the "Ignoring new object and keeping existing one" message) was repeated many times (more than 20?). It appears to display one entry for each email that I had opened in Outlook... I've obfuscated and left a single entry for illustration, but you can probably reproduce if you make this call while Outlook is open.