Allow textContains and regex selectors via official On.* MatchPattern - #3
Draft
tonycoder-hub wants to merge 1 commit into
Draft
Allow textContains and regex selectors via official On.* MatchPattern#3tonycoder-hub wants to merge 1 commit into
tonycoder-hub wants to merge 1 commit into
Conversation
UiObject.__verify rejected textContains as "not allowed". HarmonyOS uitest has no On.textContains; fuzzy/regex matching is On.text(value, MatchPattern) (CONTAINS=1, REG_EXP=4, etc.). Map Python aliases to that two-arg API, keep exact selectors single-arg, and add no-device tests. Fixes codematrixer#53 Co-authored-by: Tony Jin <407243179@qq.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes codematrixer/hmdriver2#53:
d(textContains=...)was rejected byUiObject.__verifyastextContains is not allowed.Cause
The allowlist in
_uiobject.pyonly accepted exactOn.*names (text,description,id, …). HarmonyOS uitest /@ohos.UiTestdoes not exposeOn.textContainsorOn.textMatches. Fuzzy and regex matching are the official two-arg form:MatchPattern(OpenHarmony js-apis-uitest):EQUALS=0,CONTAINS=1,STARTS_WITH=2,ENDS_WITH=3,REG_EXP=4(API 18+),REG_EXP_ICASE=5(API 18+).Change
textContains,textMatches,descriptionContains, …).On.text(value, 1)/On.text(value, 4), etc.On.text(value)so the wire format does not change.On.*(e.g.text+textContains).On.textContainsmethod names.Tests
tests/test_selector.pycovers the allowlist and selector construction with a fake client (no device). 16 passed.Regex (
REG_EXP) requires uitest API 18+ on the device. Older images still getCONTAINS/STARTS_WITH/ENDS_WITHviaOn.text.