WinAppDriver icon indicating copy to clipboard operation
WinAppDriver copied to clipboard

FindElement returns itself instead of its child

Open schrdori opened this issue 6 years ago • 3 comments

Hello,

I want to send Keys to a textbox inside a combobox. Problem is the combobox and descendant elements have the same Automation Id. Inspect tool looks like this: grafik [This is part of the 'Open File Dialog' from Windows 10 which my program uses] All three elements (pane, combo box and edit) have the Automation Id "1148" I want to address the third one directly to send the .Clear() command before sending new Keys. So what i came up with: parentElement.FindElementByAccessibilityId("1148").FindElementByAccessibilityId("1148").FindElementByAccessibilityIdntByName("1148"); Sadly this is not working. parentElement.FindElementByAccessibilityId("1148") returns the exact same element as parentElement.FindElementByAccessibilityId("1148").FindElementByAccessibilityId("1148").[...]

The issue is why can i find the element itself when searching for descendants?

schrdori avatar Jan 09 '20 12:01 schrdori

Try SendKeys on the "Enter file name" pane once the dialog is shown. I faced a somewhat similar problem while writing automation scripts for testing of an Excel Add-In. I noticed that once the window is opened, the control goes to the file path textbox by default. I just waited for the dialog to show up with WebDriverWait and performed a send key on the main pop-up. It worked :)

naeemakram avatar Jan 09 '20 16:01 naeemakram

I did try but it didn't work. AppiumWebElement.SendKeys() or AppiumWebElement.Clear() wont work on the pane. Using the actions did the trick:

var action = new Actions(Element.WrappedDriver);
action .Click(Element) .SendKeys(text) .Perform( );

schrdori avatar Jan 10 '20 14:01 schrdori

Great! This one's resolved :)

naeemakram avatar Jan 12 '20 12:01 naeemakram