{"id":24624975,"url":"https://github.com/tobyqin/wpath","last_synced_at":"2025-08-21T07:13:29.078Z","repository":{"id":58226167,"uuid":"59577683","full_name":"tobyqin/wpath","owner":"tobyqin","description":"WPath is a library to select Windows UI automatin element like XPath.","archived":false,"fork":false,"pushed_at":"2017-05-09T06:45:19.000Z","size":81,"stargazers_count":27,"open_issues_count":1,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-07T17:12:27.458Z","etag":null,"topics":["uia","uiautomation","xpath"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tobyqin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-24T13:55:08.000Z","updated_at":"2024-06-30T17:33:08.000Z","dependencies_parsed_at":"2022-08-31T04:10:35.942Z","dependency_job_id":null,"html_url":"https://github.com/tobyqin/wpath","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobyqin%2Fwpath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobyqin%2Fwpath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobyqin%2Fwpath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobyqin%2Fwpath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tobyqin","download_url":"https://codeload.github.com/tobyqin/wpath/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252922343,"owners_count":21825639,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["uia","uiautomation","xpath"],"created_at":"2025-01-25T04:12:20.020Z","updated_at":"2025-05-07T17:12:27.789Z","avatar_url":"https://github.com/tobyqin.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![NuGet](https://img.shields.io/nuget/v/WPath.svg)](https://www.nuget.org/packages/WPath)\n\n# WPath Introduction\nWPath is a library to select Windows UI automation element like XPath. The WPath looks like [XPath][1] which was wildly using to select xml elements, but it is not exactly equal to [XPath][1],  it is being used to locate [Microsoft UIAutomation][2] elements. Some special rules list below.\n\n### Installation\n\nYou can clone the repository and compile source code by yourself. Or just install via nuget packages.\n\n```\nPM\u003e Install-Package WPath\n```\n\n### Get Started\n\n1. The path should be started with '/'.\n2. Use '/' to separate element nodes in a path.\n3. The node name should be [control type][3] name, but it's optional.\n4. The UI element properties are treated as attribute in XPath.\n5. Supported attributes:\n  + `Name` (NameProperty)\n  + `ID` (AutomationIdProperty)\n  + `Class` (ClassNameProperty)\n  + `Enabled` (IsEnabledProperty)\n  + `FrameworkID` (FrameworkIdProperty)\n\n### Examples:\n\n\u003e `/Group/Button`\n  + Find the first button under first group element.\n\n\u003e `//Button[@Name='Save']`\n  + Find a button with name \"Save\" in descendants.\n\n\u003e `/[@Name='TabContainer']/Button[2]`\n  + Find the second button under an element named with 'TabContainer'\n\n\u003e `/Button[@ID='AddButton' and @Name='Add']`\n  + Find a button with automation ID 'AddButton' **and** name 'Add'\n\n\u003e `/Button[@ID='AddButton' or @Name='Add']`\n  + Find a button with automation ID 'AddButton' **or** name 'Add'\n\n\u003e `/Button[first()]`\n  + Find the first button under current node\n\n\u003e `/Button[last()]`\n  + Find the last button under current node\n\n### Usage\n\n1. Set WPath by attribute, works for C# function and property member.\n\n```cs\n[WPath(\"/Edit[@id='txtId' or @Class='TextBox']\")]\npublic AutomationElement EditControl\n{\n   get { return this.AppElement.FindByWPath(); }\n}\n\n[WPath(\"/Button[first()]\")]\npublic AutomationElement GetFirstButton()\n{\n   return this.AppElement.FindByWPath();\n}\n```\n\n2. Call `FindByWPath(path)` method to locate the element\n\n```cs\nvar path = \"/Edit[3]\";\nvar e = this.AppElement.FindByWPath(path);\nAssert.AreEqual(\"txtKey\", e.Current.AutomationId);\nAssert.AreEqual(ControlType.Edit, e.Current.ControlType);\n\npath = \"/Button[@name='OK']/Text[1]\";\ne = this.AppElement.FindByWPath(path);\nAssert.AreEqual(\"OK\", e.Current.Name);\nAssert.AreEqual(ControlType.Text, e.Current.ControlType);\n```\n\n### Tips:\n- The node name and attribute name is case insensitive\n  - @name = @Name\n  - /edit = /Edit\n- Welcome to extend the feature by sending pull requests.\n- Parent element locator `../` is **not** support yet.\n- For more usage please refer to [unit test examples][4].\n\n[1]: http://www.w3schools.com/xsl/xpath_intro.asp\n[2]: https://msdn.microsoft.com/en-us/library/ms747327(v=vs.110).aspx\n[3]: https://msdn.microsoft.com/en-us/library/ms743581(v=vs.110).aspx\n[4]: https://github.com/tobyqin/wpath/blob/master/WPath.Tests/UnitTests.cs\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobyqin%2Fwpath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftobyqin%2Fwpath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobyqin%2Fwpath/lists"}