GDATASoftwareAG / robotframework-flaui

Windows user interface automation library for Robot-Framework. FlaUILibrary is a wrapper for the FlaUI automation library.
MIT License
60 stars 12 forks source link

Element Not Available Exception #211

Open noubar opened 2 days ago

noubar commented 2 days ago

I am getting very often this error while using the reliable clicks, even it is catched The SUT is a wpf tested with UIA2.

I will be investigating further within this issue.

ElementNotAvailableException: The target element corresponds to UI that is no longer available (for example, the parent window has closed).
   at MS.Internal.Automation.Misc.ThrowWin32ExceptionsIfError(Int32 errorCode)
   at MS.Internal.Automation.Misc.GetWindowLong(HWND hWnd, Int32 nIndex)
   at MS.Internal.Automation.HwndProxyElementProvider.IsWindowPatternWindow(HWND hwnd)
   at MS.Internal.Automation.HwndProxyElementProvider.System.Windows.Automation.Provider.IRawElementProviderSimple.GetPropertyValue(Int32 propertyId)
   at MS.Internal.Automation.UiaCoreApi.CheckError(Int32 hr)
   at System.Windows.Automation.AutomationElement.GetCurrentPropertyValue(AutomationProperty property, Boolean ignoreDefaultValue)
   at FlaUI.Core.FrameworkAutomationElementBase.TryGetPropertyValue[T](PropertyId property, T& value)
   at FlaUI.Core.AutomationElementXPathNavigator.get_LocalName()
   at MS.Internal.Xml.XPath.XPathAxisIterator.get_Matches()
   at MS.Internal.Xml.XPath.XPathChildIterator.MoveNext()
   at MS.Internal.Xml.XPath.ChildrenQuery.Advance()
   at MS.Internal.Xml.XPath.FilterQuery.Advance()
   at MS.Internal.Xml.XPath.ChildrenQuery.Advance()
   at MS.Internal.Xml.XPath.FilterQuery.Advance()
   at MS.Internal.Xml.XPath.XPathSelectionIterator.MoveNext()
   at FlaUI.Core.AutomationElements.AutomationElement.FindFirstByXPath(String xPath)
noubar commented 2 days ago

If I edit this line and remove the ElementNotAvailableException, the problem will disappear

https://github.com/GDATASoftwareAG/robotframework-flaui/blob/main/src/FlaUILibrary/flaui/module/element.py#L232