Status Update
Comments
pe...@google.com <pe...@google.com> #2
You can provide your own regex to By.text()
.
For example, By.text(Pattern.compile("All albums.*", Pattern.DOTALL))
should be equivalent to a multi-line startsWith.
to...@gmail.com <to...@gmail.com> #3
I'm probably dumb but why would it be the default and wanted behavior if not documented properly?
Every known startWith / contains function in Java/Kotlin are multiline, the javadoc says: A UI element will be considered a match if its text value starts with the substring parameter
Many people will fall into this non standard default behavior and loose tons of time trying to figure out why.
If you still consider this default is the correct one, then please document it.
ap...@google.com <ap...@google.com> #4
Branch: androidx-main
commit 1625e615b9aed44323029da2726a57390956e4ab
Author: Daniel Peykov <peykov@google.com>
Date: Wed Nov 02 21:46:28 2022
Support multiline text and description matching
* Fixes inconsistency between UiSelector (partial support) and
BySelector, and clarifies the case sensitivity of related methods.
* Also, reorganizes byselector_test_activity to decrease its height
which was right up to the limit on some device types.
Bug: 255787130
Test: ./gradlew :test:uiautomator:integration-tests:t:cAT
Change-Id: Ied9eff43ce4ce6f2ace2889a55b0382e71604b61
M test/uiautomator/integration-tests/testapp/src/androidTest/java/androidx/test/uiautomator/testapp/BySelectorTest.java
M test/uiautomator/integration-tests/testapp/src/main/res/layout/byselector_test_activity.xml
M test/uiautomator/uiautomator/src/main/java/androidx/test/uiautomator/BySelector.java
M test/uiautomator/uiautomator/src/main/java/androidx/test/uiautomator/UiSelector.java
M test/uiautomator/uiautomator/src/main/java/androidx/test/uiautomator/Until.java
pe...@google.com <pe...@google.com> #5
Will be fixed in version 2.3.0-alpha02.
To clarify
However, looking at this again, it was inconsistent between UiSelector and BySelector, and users are unlikely to be relying on single line matching.
to...@gmail.com <to...@gmail.com> #6
Thanks a lot for the change.
I understand legacy and everything, it was just the close without discussion about proper solution (including doc that would have worked too) that was strange.
Seeing the $ in the regexp took me time, and it's good to avoid this to other users when improvement is possible.
na...@google.com <na...@google.com> #7
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.test.uiautomator:uiautomator:2.3.0-alpha02
Description
Artifact used (ex. androidx.appcompat:appcompat:1.0.0-alpha1): UIAutomator Version used: 2.2.0
I have a simple Compose UI with a
Text(text = "$title\n ")
UIAutomator dump says:
<node index="0" text="All albums " resource-id="" ...
This element can't be find with the current
By.textContains
andBy.textStartsWith
. I'm not regex expert but I think the $ without enabling multiline in the regexp is the cause.