fix: Update "find elements using"-strings #334
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Appium-clients can't use the iOS Class Chain and iOS Predicate String queries because the strings WDA expects don't match the strings the clients send.
Expected behaviour
When the client (I'm using the Python-client, but behaviour in other clients should be the same) requests to find elements using a class chain or predicate string WebElements matching the query should be returned if any are found.
Actual behaviour
Requesting to find elements results in an error because the WDA doesn't know how to handle the strings sent by the client.
Proposed fix
Change WDA to match the strings the clients are sending, i.e. prepend "-ios " to the "class chain" and "predicate string" usingTexts.
While it might seem backwards to change this in the server rather than adapt the clients, because multiple clients already use the same string and the "-ios "-prefix seems to have been established (in order to differentiate between lookup strategies that work exclusively on the iOS server) adapting the server seems like the more straight-forward fix.
Background
I've tried to find out when changes were introduced that made the server and client behaviour diverge but it turns out the respective strings have remained unchanged from when they were added around 3 years ago. I only tested the Python client because that's what I'm working with right now but searched through the other clients and all that have added support for class chain and predicate string lookups share the same strings, so the problem should exist for all of them. From what I can see none of those clients has been able to use these lookup strategies for years which seems odd but accurate from my research. I have found six clients linked from the official Appium documentation that all use the same "-ios..."-strings, so they seem to be an established pattern and fixing the server should make all of them work at the same time instead of having to fix all clients individually (it also seems like a reasonable idea to specially format strategies that work exclusively on iOS and are not supported by other Appium/Selenium servers).
Relevant GitHub code, issues and PRs: