WinAppDriver
WinAppDriver copied to clipboard
Unable to locate the elements within excel by inspect.exe
I'm trying to automate excel application and I couldn't able to locate the drop down control neither by inspect.exe nor by UIWinAppDriverUiRecorder.exe. Is there any other way to identify this element which is highlighted in the screen shot. Any help on this will be greatly appreciated.

Here is a workaround you can try:
-
Click on target cell to show the dropdown button
-
Move cursor to next cell on the right by calling MouseMove with an offset
-
Cursor should now be on top of the dropdown button, so click on it
// LeftClick on DataItem ""E" 7" at (216,22) Console.WriteLine("LeftClick on DataItem \""E" 7\" at (216,22)"); string xpath_LeftClickDataItemE7_216_22 = "/Pane[@ClassName=\"#32769\"][@Name=\"Desktop 1\"]/Window[@ClassName=\"XLMAIN\"][@Name=\"Book1 - Excel\"]/Pane[@ClassName=\"XLDESK\"]/Tab[@Name=\"Book1\"][starts-with(@AutomationId,\"Book\")]/TabItem[@Name=\"Sheet Sheet1\"][starts-with(@AutomationId,\"Sheet\")]/DataGrid[@Name=\"Grid\"][@AutomationId=\"Grid\"]/DataItem[@Name=\""E" 7\"]"; var winElem_LeftClickDataItemE7_216_22 = desktopSession.FindElementByAbsoluteXPath(xpath_LeftClickDataItemE7_216_22); if (winElem_LeftClickDataItemE7_216_22 != null) { // 1) Click on cell to show drop down button winElem_LeftClickDataItemE7_216_22.Click(); System.Threading.Thread.Sleep(1000); // 2) Move cursor to next cell on the right by calling MouseMove with an offset desktopSession.DesktopSessionElement.Mouse.MouseMove(winElem_LeftClickDataItemE7_216_22.Coordinates, winElem_LeftClickDataItemE7_216_22.Size.Width + 5, winElem_LeftClickDataItemE7_216_22.Size.Height / 2); // 3) Click on drop down button desktopSession.DesktopSessionElement.Mouse.Click(null); } else { Console.WriteLine($"Failed to find element using xpath: {xpath_LeftClickDataItemE7_216_22}"); return; }
Thanks @JunlinZhu'. I tried the work around and it's working.