microsoft / WinAppDriver

Windows Application Driver
MIT License
3.54k stars 1.39k forks source link

Problem in UI Automation using WinAppDriver #1953

Open RamyaThirumalaisamy opened 6 months ago

RamyaThirumalaisamy commented 6 months ago

I am doing UI Automation for windows desktop WPF application using WinAppDriver. The problem is I Couldn’t able to access one button. I Can able to see the button in GUI. But in the page source of the WinAppDriver the button is not listed. I used Live Visual Tree option in Visual Studio and WinAppDriverUIRecorder to find more details about the button and I am providing the details here.

1) In Live Visual Tree the Hierarchy of the button will be something like this, image Here I want to access the highlighted button.

2) I Would like to show the button details in WinAppDriverUIRecorder, image In WinAppDriverUIRecorder, If I hover over the mouse to the button I wanted, I am getting the above result.

3) WinAppDriver’s Page Source

<ListItem AcceleratorKey="" AccessKey="" AutomationId="" ClassName="RowControl" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="True" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="list item" Name="Update using Debugger " Orientation="None" ProcessId="13152" RuntimeId="7.13152.59357728" x="753" y="521" width="1165" height="42" ExpandCollapseState="LeafNode" IsAvailable="True">
                    <Edit AcceleratorKey="" AccessKey="" AutomationId="" ClassName="CellEditor" FrameworkId="WPF" HasKeyboardFocus="False" HelpText="" IsContentElement="True" IsControlElement="True" IsEnabled="True" IsKeyboardFocusable="True" IsOffscreen="False" IsPassword="False" IsRequiredForForm="False" ItemStatus="" ItemType="" LocalizedControlType="edit" Name="Update using Debugger " Orientation="None" ProcessId="13152" RuntimeId="7.13152.66884519" x="992" y="521" width="926" height="40" />
 </ListItem>

With help of above page source I tried to access the edit part, it is accessing (means clicking) the combo box near to the Detect button. If I tried to access the ListItem, it is accessing(Clicking) the “Update using Debugger” part (left side).

The UI part is this, Here I am trying to access the Detect button.

image I am believing that If I can able to see the detect button details in page source I Can easily access the button via automation id or XPath whatever it may be.

My Questions :

1) Why this button is not visible in page source? Do I need to do some more action in the UI to get visible of the button in Page source? 2) While hovering over the mouse near to the detect button WinAppDriverUIRecorder is not able to identify the button alone. Instead of it, It Identifies the whole right side part of the “Update using Debugger”. Why this is happening? Is it because of WPF Controls the way attached in UI or something else? I am Expecting WinAppDriver to do this, image But what is happening really is, image 3) By clicking the menu button near to "Programming (Firmware & Config)" will help me to get the detect button details in page source? Is this the way I am thinking to get rid of the problem is right? If not kindly direct me in right way! Thanks in advance!

RakeshDangi-slt commented 5 months ago

@RamyaThirumalaisamy Use inspect.exe from windows sdk tool kit to see the elements properties, then create an xpath with combination of different values which does not match any other element something like this'//*[@Name='Annotation Panel' and @LocalizedControlType='pane']', then perform your action and issue will be resolved.