{"action":"opened","issue":{"url":"https://api.github.com/repos/Roemer/FlaUI/issues/172","repository_url":"https://api.github.com/repos/Roemer/FlaUI","labels_url":"https://api.github.com/repos/Roemer/FlaUI/issues/172/labels{/name}","comments_url":"https://api.github.com/repos/Roemer/FlaUI/issues/172/comments","events_url":"https://api.github.com/repos/Roemer/FlaUI/issues/172/events","html_url":"https://github.com/Roemer/FlaUI/issues/172","id":329430952,"node_id":"MDU6SXNzdWUzMjk0MzA5NTI=","number":172,"title":"PropertyNotSupportedException when searching by XPath and elements without property in search tree","user":{"login":"lukasvogel","id":1242460,"node_id":"MDQ6VXNlcjEyNDI0NjA=","avatar_url":"https://avatars1.githubusercontent.com/u/1242460?v=4","gravatar_id":"","url":"https://api.github.com/users/lukasvogel","html_url":"https://github.com/lukasvogel","followers_url":"https://api.github.com/users/lukasvogel/followers","following_url":"https://api.github.com/users/lukasvogel/following{/other_user}","gists_url":"https://api.github.com/users/lukasvogel/gists{/gist_id}","starred_url":"https://api.github.com/users/lukasvogel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukasvogel/subscriptions","organizations_url":"https://api.github.com/users/lukasvogel/orgs","repos_url":"https://api.github.com/users/lukasvogel/repos","events_url":"https://api.github.com/users/lukasvogel/events{/privacy}","received_events_url":"https://api.github.com/users/lukasvogel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-05T12:21:07Z","updated_at":"2018-06-05T12:21:07Z","closed_at":null,"author_association":"NONE","body":"This issue occurs if you search by XPath for an element by property.\r\nIf not ALL elements in the search tree support the given property, the search will fail with a PropertyNotSupportedException:\r\n\r\n```\r\nFlaUI.Core.Exceptions.PropertyNotSupportedException : The requested property 'AutomationId [#30011]' is not supported\r\n   bei FlaUI.Core.FrameworkAutomationElementBase.GetPropertyValue[T](PropertyId property)\r\n   bei FlaUI.Core.AutomationProperty`1.get_Value()\r\n   bei FlaUI.Core.AutomationElementXPathNavigator.GetAttributeValue(Int32 attributeIndex)\r\n   bei FlaUI.Core.AutomationElementXPathNavigator.get_Value()\r\n   bei MS.Internal.Xml.XPath.LogicalExpr.cmpQueryNumber(Op op, Object val1, Object val2)\r\n   bei MS.Internal.Xml.XPath.LogicalExpr.Evaluate(XPathNodeIterator nodeIterator)\r\n   bei MS.Internal.Xml.XPath.FilterQuery.EvaluatePredicate()\r\n   bei MS.Internal.Xml.XPath.FilterQuery.Advance()\r\n   bei MS.Internal.Xml.XPath.XPathSelectionIterator.MoveNext()\r\n   bei FlaUI.Core.AutomationElements.AutomationElement.FindAllByXPath(String xPath)\r\n   bei FlaUI.Core.UITests.XPathTests.NotepadFindByAutomationId() in C:\\Users\\lukie\\Source\\Repos\\FlaUI\\src\\FlaUI.Core.UITests\\XPathTests.cs:Zeile 65.\r\n```\r\n\r\nYou can, for example, trigger it in Paint like this:\r\n```\r\npublic void NotepadFindByAutomationId()\r\n{\r\n    using (var automation = TestUtilities.GetAutomation(AutomationType.UIA3))\r\n    {\r\n        var app = Application.Launch(\"notepad.exe\");\r\n        var window = app.GetMainWindow(automation);\r\n        var elem = window.FindAllByXPath(\"//*[@AutomationId=15]\");\r\n        Assert.That(elem.Length, Is.EqualTo(1));\r\n        app.Close();\r\n    }\r\n}\r\n```\r\n\r\nThe offending piece of code:\r\nhttps://github.com/Roemer/FlaUI/blob/51573d67cd1758462148b4e6f62ee9f107c079cd/src/FlaUI.Core/AutomationElementXPathNavigator.cs#L255-L270\r\n\r\nRetrieving a value that does not exist results in this method throwing an exception aborting the search. \r\nI think it'd be better to use getValueOrDefault() instead."}}
{"actor":{"display_login":"lukasvogel"}}