各位大神们,本人刚刚入门自学移动端自动化测试,在编写代码过程中出现标题所述问题,一直找不到解决方法,请求各位大神帮助
测试环境应用
appium 版本 1.4.16.1
系统:Win7X64
jar 包版本:java-client-4.0.0,selenium-java-2.53.0
安卓模拟器为 Nexus 5 ,安卓版本为 5.1.1,API 22
使用 JAVA 语言,首先设置默认键盘已经设置
capabilities.setCapability("unicodeKeyboard", "True");
capabilities.setCapability("resetKeyboard", "True");
输入语句如下,其中 driver 定义的是 AndroidDriver
driver.findElementById("com.ccz.insure:id/et_car_owner_id_number").clear();
driver.findElementById("com.ccz.insure:id/et_car_owner_id_number").sendKeys("510623198408133813");
我将以上语句转换成 web 后实验也不行,log 信息如下,发送的 510623198408133813,在 APP 上面显示出来的是 551062311988408138813

info: [debug] [BOOTSTRAP] [debug] Clearing text not successful. Attempting to clear by selecting all and deleting.
info: [debug] [BOOTSTRAP] [debug] Clearing text not successful. Attempting to clear by sending delete keys.
info: [debug] [BOOTSTRAP] [debug] Text remains after clearing, but it appears to be hint text.
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":true}
info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"5e45f4aa-e642-4a74-8ab9-372c0f005d54"}
info: <-- POST /wd/hub/session/5e45f4aa-e642-4a74-8ab9-372c0f005d54/element/4/clear 200 21608.356 ms - 76 {"status":0,"value":true,"sessionId":"5e45f4aa-e642-4a74-8ab9-372c0f005d54"}
info: --> POST /wd/hub/session/5e45f4aa-e642-4a74-8ab9-372c0f005d54/element {"using":"id","value":"com.ccz.insure:id/et_car_owner_id_number"}
info: [debug] Waiting up to 30000ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.ccz.insure:id/et_car_owner_id_number","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.ccz.insure:id/et_car_owner_id_number","context":"","multiple":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding com.ccz.insure:id/et_car_owner_id_number using ID with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.ccz.insure:id/et_car_owner_id_number]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":{"ELEMENT":"5"}}
info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"5"},"sessionId":"5e45f4aa-e642-4a74-8ab9-372c0f005d54"}
info: <-- POST /wd/hub/session/5e45f4aa-e642-4a74-8ab9-372c0f005d54/element 200 131.033 ms - 87 {"status":0,"value":{"ELEMENT":"5"},"sessionId":"5e45f4aa-e642-4a74-8ab9-372c0f005d54"}
info: --> POST /wd/hub/session/5e45f4aa-e642-4a74-8ab9-372c0f005d54/element/5/value {"id":"5","value":["510623198408133813"]}
info: [debug] Pushing command to appium work queue: ["element:setText",{"elementId":"5","text":"510623198408133813","replace":false,"unicodeKeyboard":true}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:setText","params":{"elementId":"5","text":"510623198408133813","replace":false,"unicodeKeyboard":true}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: setText
info: [debug] [BOOTSTRAP] [debug] Using element passed in.
info: [debug] [BOOTSTRAP] [debug] Attempting to clear using UiObject.clearText().
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: 510623198408133813
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":true}
info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"5e45f4aa-e642-4a74-8ab9-372c0f005d54"}
info: <-- POST /wd/hub/session/5e45f4aa-e642-4a74-8ab9-372c0f005d54/element/5/value 200 8248.934 ms - 76 {"status":0,"value":true,"sessionId":"5e45f4aa-e642-4a74-8ab9-372c0f005d54"}
info: --> POST /wd/hub/session/5e45f4aa-e642-4a74-8ab9-372c0f005d54/element {"using":"id","value":"com.ccz.insure:id/et_car_owner_tel"}
info: [debug] Waiting up to 30000ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.ccz.insure:id/et_car_owner_tel","context":"","multiple":false}]


↙↙↙阅读原文可查看相关链接,并与作者交流