2

Greetings and salutations!

I'm working on a UI automation project for a windows desktop app (FrameworkId: Win32) Stack: Python (3.7) + Appium (1.15.1) + WinAppDriver (v1.1).

I have identified an element using Inspect.exe, but when I try to code, whatever I do I receive this error: selenium.common.exceptions.NoSuchElementException: Message: An element could not be located on the page using the given search parameters.

The locator strategy I'm using is xpath: self.driver.find_element_by_xpath("//*[@LocalizedControlType='text' and @IsControlElement='false']")

As you can see, Inspect.exe has shown that it has the property "IsControlElement='false'", but I cannot for the life of me "access" it via code.

I would also like to point out that any elements that had the IsControlElement='true' are properly found and I can "interact" with them.

Thank you very much for your help!

1 Answers1

0

Source of issue

This is probably an issue within Microsoft's UI Automation implementation in .NET. The property IsControlElement should have returned true while it didn't.

From my tests, it seems to be an issue somewhere within UIAutomationCore.dll.

I speculate that the root cause is that the automation implementation was targeted for accessibility in mind, and they have mistakenly ignored some controls which are NOT readable (Image, Geometry, etc.).

Workaround for some cases

  • Try to use UI control from a type that has a text.
  • if it's already a textual control, try to use a different textual control type. for example - in WPF project - use Label instead of TextBlock
  • if it's NOT a textual element, if possible, wrap the control in a textual element. in WPF projects you can use a <Label Padding="0"> as a wrapper.

Other things to consider

Related issues

Side Note

Since you haven't specified which Python GUI library are you using, I was not able to provide examples for your library. Sorry.

itsho
  • 4,111
  • 3
  • 37
  • 61
  • Hello Itsho! Thank you for your response! The Python GUI library used is win32all if I'm not mistaken. – Fabian Tölgyi Jan 17 '20 at 07:29
  • I've used **pywinauto** to automate the same thing and, what I ended up doing was using "sort of an xpath" approach where I took the .child_window(criteria).children()[x] .children()[y] and the got reached the element I needed to interact with \ read. Is there any way to do from within Appium? – Fabian Tölgyi Jan 17 '20 at 07:34
  • I mean I know you can access an element with `driver.find_element_by_xpath("//*[@attribute='value']")` but not entirely sure what do from there. – Fabian Tölgyi Jan 17 '20 at 07:35
  • What I've also found is that if you do try something like this: `driver.find_element_by_xpath("//*[@attribute='value']/*")` this would take you to the next node that does have `IsControlElement="True"`, so that's a start anyway. – Fabian Tölgyi Jan 17 '20 at 07:38