mirror of
https://github.com/appium/appium.git
synced 2026-02-14 05:50:00 -06:00
Merge pull request #3785 from paymand/hint_text_detection
Made clearing text faster on Android when there is hint text.
This commit is contained in:
@@ -53,6 +53,13 @@ public class Clear extends CommandHandler {
|
||||
|
||||
final ReflectionUtils utils = new ReflectionUtils();
|
||||
|
||||
// see if there is hint text
|
||||
if (hasHintText(el, utils)) {
|
||||
Logger.debug("Text remains after clearing, "
|
||||
+ "but it appears to be hint text.");
|
||||
return getSuccessResult(true);
|
||||
}
|
||||
|
||||
// next try to select everything and delete
|
||||
Logger.debug("Clearing text not successful. Attempting to clear " +
|
||||
"by selecting all and deleting.");
|
||||
@@ -60,6 +67,13 @@ public class Clear extends CommandHandler {
|
||||
return getSuccessResult(true);
|
||||
}
|
||||
|
||||
// see if there is hint text
|
||||
if (hasHintText(el, utils)) {
|
||||
Logger.debug("Text remains after clearing, "
|
||||
+ "but it appears to be hint text.");
|
||||
return getSuccessResult(true);
|
||||
}
|
||||
|
||||
// finally try to send delete keys
|
||||
Logger.debug("Clearing text not successful. Attempting to clear " +
|
||||
"by sending delete keys.");
|
||||
@@ -141,6 +155,9 @@ public class Clear extends CommandHandler {
|
||||
String currText = el.getText();
|
||||
|
||||
final Method sendKey = utils.getControllerMethod("sendKey", int.class, int.class);
|
||||
sendKey.invoke(utils.getController(), KeyEvent.KEYCODE_DPAD_RIGHT, 0);
|
||||
sendKey.invoke(utils.getController(), KeyEvent.KEYCODE_DEL, 0);
|
||||
sendKey.invoke(utils.getController(), KeyEvent.KEYCODE_DPAD_LEFT, 0);
|
||||
sendKey.invoke(utils.getController(), KeyEvent.KEYCODE_DEL, 0);
|
||||
|
||||
return currText.equals(el.getText());
|
||||
|
||||
Reference in New Issue
Block a user