环境
appium:1.3.4.1
语言:java
手机操作系统:android4.4.4
需求
不清空原 EditText 内容,继续输入内容
目前尝试
1.
findElementByXPath("//android.widget.EditText").sendKeys("测试");
findElementByXPath("//android.widget.EditText").sendKeys("a");
结果
第二次 sendKeys("a"),会清空原输入内容"测试"再输入"a"
2.
findElementByXPath("//android.widget.EditText").sendKeys("测试");
findElementByXPath("//android.widget.EditText").click();
findElementByXPath("//android.widget.EditText").sendKeys("a");
结果
还是会清空原输入内容
本人菜鸟中的菜鸟,请大神们指导一下这个要咋整
负责任的告诉你,不清除是不可能的,死了这个心吧!so ,现在说一下你的需求,我们可以绕道实现之
你可以先把 EditText 里面的 value 取出来放到一个 string 里, 最后你 click 后 sendkeys 传一个新的 String 这个 String 你自己拼个新的 value+ " 你想输入的" 试试
我记得之前有个同学发帖子提过自己扩展 appium 来实现
只能拓展重写 sendkeys 方法了吧。 appium 里 sendkeys 方法中,执行 input 之前就是有 clear 操作的。
采用 adb input 命令输入,input text,input keyevent 输入字符
@weamylady 在定位焦点时,比较懒的做法是可以这么做,不管焦点定位在什么点,可以使用右移光标的 keyevent,循环的次数可以根据输入内容的长短确定,次数尽量可以多些。光标又移的命令:adb shell input keyevent 22。
觉得还是先存在一个临时变量里比较靠谱
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: setText
info: [debug] [BOOTSTRAP] [debug] Attempting to clear using UiObject.clearText().
info: [debug] [BOOTSTRAP] [debug] Updating class "class com.android.uiautomator.core.UiDevice" to enable field "mUiAutomationBridge"
info: [debug] [BOOTSTRAP] [debug] Updating class "class com.android.uiautomator.core.UiAutomatorBridge" to enable field "mInteractionController"
info: [debug] [BOOTSTRAP] [debug] Clearing text not successful. Attempting to clear by selecting all and deleting.
info: [debug] [BOOTSTRAP] [debug] Updating class "class com.android.uiautomator.core.UiDevice" to enable field "mUiAutomationBridge"
info: [debug] [BOOTSTRAP] [debug] Updating class "class com.android.uiautomator.core.UiAutomatorBridge" to enable field "mInteractionController"
info: [debug] [BOOTSTRAP] [debug] Finding methods on class: class com.android.uiautomator.core.InteractionController
info: [debug] [BOOTSTRAP] [debug] Finding methods on class: class com.android.uiautomator.core.InteractionController
info: [debug] [BOOTSTRAP] [debug] Finding methods on class: class com.android.uiautomator.core.InteractionController
info: [debug] [BOOTSTRAP] [debug] Clearing text not successful. Attempting to clear by sending delete keys.
info: [debug] [BOOTSTRAP] [debug] Finding methods on class: class com.android.uiautomator.core.UiAutomatorBridge
info: [debug] [BOOTSTRAP] [debug] Finding methods on class: class com.android.uiautomator.core.InteractionController
info: [debug] [BOOTSTRAP] [debug] Text remains after clearing, but it appears to be hint text.
info: [debug] [BOOTSTRAP] [debug] Text not cleared. Assuming remainder is hint text.
info: [debug] [BOOTSTRAP] [debug] Sending plain text to element: 123
请问楼主,你这个问题最后是采用哪种方法解决的呀,我现在也遇到同样的问题,但我是初学者,不知道具体用哪种方法能解决呀