-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
[Android] Search all by text #301
Comments
diff --git a/uiautomator/bootstrap/src/io/appium/android/bootstrap/AndroidCommandHolder.java b/uiautomator/bootstrap/src/io/appium/android/bootstrap/
index 0027561..ad18605 100644
--- a/uiautomator/bootstrap/src/io/appium/android/bootstrap/AndroidCommandHolder.java
+++ b/uiautomator/bootstrap/src/io/appium/android/bootstrap/AndroidCommandHolder.java
@@ -220,14 +220,11 @@ class AndroidCommandHolder {
private static UiSelector selectorForFind(String strategy, String selector, Boolean many) throws InvalidStrategyException, AndroidCommandExcepti
UiSelector s = new UiSelector();
if (strategy.equals("tag name")) {
+ } else if (strategy.equals("text")) {
+ s = s.textContains(selector);
} else if (strategy.equals("name")) {
s = s.description(selector);
} else {
@@ -241,4 +238,4 @@ class AndroidCommandHolder {
return s;
}
-}
\ No newline at end of file
+} This works. Some selenium bindings will not accept finding by text so it should probably be placed under xpath. |
$x("//*[contains(@href,'favico')]") Appium can't parse it though. > $driver.find_element :xpath, %(//*[contains(@text, 'agree')])
post
session/a691485b-f94a-43a2-9ad2-3d113816b863/element
{"using":"xpath","value":"//*[contains(@text, 'agree')]"}
Selenium::WebDriver::Error::XPathLookupError: Could not parse xpath data from //*[contains(@text, 'agree')] |
Is there a better place for this than XPath? |
we could use selenium's "link text". also yeah xpath doesn't support |
Link text is defined as
What about a simple implementation like this? I think there's only one valid XPath to trigger this feature. > rgx
"//*[contains(@text, 'agree')]"
> rgx.match("//\\*\\[contains\\(@text, '(.*)'\\)\\]")[1]
"agree" |
The fix seems simple enough for var root = "^(/?/?(?:[a-zA-Z]+|\\*))"; |
Android messes it up. $driver.find_element :xpath, %(//*[contains(@text, 'agree')]) info: [ANDROID] [info] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//*[contains(@text, 'agree')]","context":"","multiple":false,"path":[{"node":"*","search":"desc"}],"attr":"text","constraint":"agree","substr":true}}
info: [ANDROID] [info] Got command of type ACTION
info: [ANDROID] [info] Building xpath selector from attr text and constraint agree and substr true
info: [ANDROID] [info] s.className('android.widget.*').textContains('agree') |
I submitted #308 with a proper fix. |
Remove bash script for starting up real device
Remove bash script for starting up real device
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Android has [text contains](http://developer.android.com/tools/help/uiautomator/UiSelector.html#textContains(java.lang.String\)) so that should work.
The text was updated successfully, but these errors were encountered: