Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for XPath locator strategy #29

Open
NickAb opened this issue May 1, 2015 · 5 comments
Open

Add support for XPath locator strategy #29

NickAb opened this issue May 1, 2015 · 5 comments

Comments

@NickAb
Copy link
Contributor

NickAb commented May 1, 2015

XPath or similar (css selector-like) locator strategy might be useful for apps that have complex UIs or not quite tuned for ease of testing.

  1. XPath locator can be already implemented in driver based on PageSourceCommand and standard XmlDocument, but it will require PageSourceCommand to be modified in a way that it will save all elements to registered elements storage. Such solution is easiest for implementation at the moment, but will be very slow as it will require whole UI visual tree to be traversed and represented as XML nodes regardless of actual XPath, which can match first node.
  2. Implementing custom XmlReader, that would return nodes on the fly as needed, might be a better option in terms of performance. See Implementing XmlReader Classes for Non-XML Data Structures and Formats.
@NickAb
Copy link
Contributor Author

NickAb commented May 2, 2015

Second option needs more investigation. At least three ways to implement on the fly XPath-able collection are available:

  1. Subclassing XmlReader
  2. Implementing IXPathNavigable interface and providing custom XPathNavigator.
  3. Using XStreamingElement and Linq

Need to understand limitations and benefits of each one.

XPathNavigator seems to be a way to go. See Using XPath to Navigate the File System for reference on XPathNavigator implementation.

@NickAb
Copy link
Contributor Author

NickAb commented May 8, 2015

Implementing XPathNavigator is easy and allows to access elements only when needed, but XPathNavigator is not supported by Store Apps framework, rendering it unsuable both for current StoreApps driver and CodedUI prototype (but it can be used for desktop).

@skyline-gleb
Copy link
Contributor

Successfully used for desktop, thanks for research

@NickAb
Copy link
Contributor Author

NickAb commented May 3, 2016

Somebody packed System.Xml.XPath for Silverlight apps, see package here https://www.nuget.org/packages/System.Xml.XPath.SL4/

We should try it out

@Pranodayd
Copy link

Hi @NickAb .
I will see to implement by suggested way in "How to add support for element attributes other than ClassName, Name, AutomationId? #19 " or else I will have to wait for Xpath strategy to be implemented in Winium.StoreApps for some of the scenarios containing element retrieval based on SIBLING relationship.
Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants