• 我也想过真机比模拟器快多了可能没这个问题,但测试机器少了 没办法 自动化只能用模拟器了。😭

  • 我用了这个方法还是不能完美解决,50% 的几率能输入完整。 晕死。
    EBC_Emulator_Data.driver.find_element_by_id("com.sdwx.ebochong:id/et_license_plate").click()
    EBC_Emulator_Data.driver.press_keycode(29)
    EBC_Emulator_Data.driver.press_keycode(8)
    EBC_Emulator_Data.driver.press_keycode(10)
    EBC_Emulator_Data.driver.press_keycode(12)
    EBC_Emulator_Data.driver.press_keycode(14)
    EBC_Emulator_Data.driver.press_keycode(16)
    EBC_Emulator_Data.driver.find_element_by_id("com.sdwx.ebochong:id/rb_fuel_vechicle").click()

    你的这个方法不错,有可能解决。多谢提醒。

  • 多谢。

  • 没有手动加 sleep,因为模拟运行很慢整段代码加了 driver.implicitly_wait(15)。 另外在输入用户名的区域(用户名为纯手机号码及纯数字)用 Send_keys 没这个问题。 是不是这个地方用的控件或方法不对,造成 Send_keys 不能正常处理。

  • Log 太大了,我就选了相关一段贴出来。不知道能不能看出问题,多谢。

    Log:

    info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":true}
    info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"c9b0c668-7f4f-45e2-af6a-8cc3be476075"}
    info: <-- POST /wd/hub/session/c9b0c668-7f4f-45e2-af6a-8cc3be476075/element/4/click 200 3648.653 ms - 76 {"status":0,"value":true,"sessionId":"c9b0c668-7f4f-45e2-af6a-8cc3be476075"}
    info: --> POST /wd/hub/session/c9b0c668-7f4f-45e2-af6a-8cc3be476075/element {"sessionId":"c9b0c668-7f4f-45e2-af6a-8cc3be476075","using":"id","value":"com.sdwx.ebochong:id/et_license_plate"}
    info: [debug] Waiting up to 15000ms for condition
    info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.sdwx.ebochong:id/et_license_plate","context":"","multiple":false}]
    info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.sdwx.ebochong:id/et_license_plate","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.sdwx.ebochong:id/et_license_plate using ID with the contextId: multiple: false
    info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.sdwx.ebochong:id/et_license_plate]
    info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":{"ELEMENT":"5"}}
    info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"5"},"sessionId":"c9b0c668-7f4f-45e2-af6a-8cc3be476075"}
    info: <-- POST /wd/hub/session/c9b0c668-7f4f-45e2-af6a-8cc3be476075/element 200 2191.491 ms - 87 {"status":0,"value":{"ELEMENT":"5"},"sessionId":"c9b0c668-7f4f-45e2-af6a-8cc3be476075"}
    info: --> POST /wd/hub/session/c9b0c668-7f4f-45e2-af6a-8cc3be476075/element/5/value {"id":"5","sessionId":"c9b0c668-7f4f-45e2-af6a-8cc3be476075","value":["a","1","3","5","7","9"]}
    info: [debug] Pushing command to appium work queue: ["element:setText",{"elementId":"5","text":"a13579","replace":false,"unicodeKeyboard":true}]
    info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:setText","params":{"elementId":"5","text":"a13579","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: a13579
    info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":true}
    info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"c9b0c668-7f4f-45e2-af6a-8cc3be476075"}
    info: <-- POST /wd/hub/session/c9b0c668-7f4f-45e2-af6a-8cc3be476075/element/5/value 200 10844.194 ms - 76 {"status":0,"value":true,"sessionId":"c9b0c668-7f4f-45e2-af6a-8cc3be476075"}
    info: --> POST /wd/hub/session/c9b0c668-7f4f-45e2-af6a-8cc3be476075/element {"sessionId":"c9b0c668-7f4f-45e2-af6a-8cc3be476075","using":"id","value":"com.sdwx.ebochong:id/rb_fuel_vechicle"}
    info: [debug] Waiting up to 15000ms for condition
    info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.sdwx.ebochong:id/rb_fuel_vechicle","context":"","multiple":false}]
    info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.sdwx.ebochong:id/rb_fuel_vechicle","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.sdwx.ebochong:id/rb_fuel_vechicle using ID with the contextId: multiple: false
    info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.sdwx.ebochong:id/rb_fuel_vechicle]
    info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":{"ELEMENT":"6"}}
    info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"6"},"sessionId":"c9b0c668-7f4f-45e2-af6a-8cc3be476075"}
    info: <-- POST /wd/hub/session/c9b0c668-7f4f-45e2-af6a-8cc3be476075/element 200 620.048 ms - 87 {"status":0,"value":{"ELEMENT":"6"},"sessionId":"c9b0c668-7f4f-45e2-af6a-8cc3be476075"}
    info: --> POST /wd/hub/session/c9b0c668-7f4f-45e2-af6a-8cc3be476075/element/6/click {"id":"6","sessionId":"c9b0c668-7f4f-45e2-af6a-8cc3be476075"}
    info: [debug] Pushing command to appium work queue: ["element:click",{"elementId":"6"}]
    info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"6"}}
    info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
    info: [debug] [BOOTSTRAP] [debug] Got command action: click
    info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":true}
    info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"c9b0c668-7f4f-45e2-af6a-8cc3be476075"}
    info: <-- POST /wd/hub/session/c9b0c668-7f4f-45e2-af6a-8cc3be476075/element/6/click 200 372.895 ms - 76 {"status":0,"value":true,"sessionId":"c9b0c668-7f4f-45e2-af6a-8cc3be476075"}
    info: --> POST /wd/hub/session/c9b0c668-7f4f-45e2-af6a-8cc3be476075/element {"sessionId":"c9b0c668-7f4f-45e2-af6a-8cc3be476075","using":"id","value":"com.sdwx.ebochong:id/btn_commit"}
    info: [debug] Waiting up to 15000ms for condition
    info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.sdwx.ebochong:id/btn_commit","context":"","multiple":false}]
    info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.sdwx.ebochong:id/btn_commit","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.sdwx.ebochong:id/btn_commit using ID with the contextId: multiple: false
    info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.sdwx.ebochong:id/btn_commit]
    info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"7"},"sessionId":"c9b0c668-7f4f-45e2-af6a-8cc3be476075"}
    info: <-- POST /wd/hub/session/c9b0c668-7f4f-45e2-af6a-8cc3be476075/element 200 489.053 ms - 87 {"status":0,"value":{"ELEMENT":"7"},"sessionId":"c9b0c668-7f4f-45e2-af6a-8cc3be476075"}
    info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":{"ELEMENT":"7"}}
    info: --> POST /wd/hub/session/c9b0c668-7f4f-45e2-af6a-8cc3be476075/element/7/click {"id":"7","sessionId":"c9b0c668-7f4f-45e2-af6a-8cc3be476075"}
    info: [debug] Pushing command to appium work queue: ["element:click",{"elementId":"7"}]
    info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"7"}}
    info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
    info: [debug] [BOOTSTRAP] [debug] Got command action: click
    info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":true}
    info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"c9b0c668-7f4f-45e2-af6a-8cc3be476075"}
    info: <-- POST /wd/hub/session/c9b0c668-7f4f-45e2-af6a-8cc3be476075/element/7/click 200 3258.352 ms - 76 {"status":0,"value":true,"sessionId":"c9b0c668-7f4f-45e2-af6a-8cc3be476075"}
    info: --> POST /wd/hub/session/c9b0c668-7f4f-45e2-af6a-8cc3be476075/element {"sessionId":"c9b0c668-7f4f-45e2-af6a-8cc3be476075","using":"id","value":"com.sdwx.ebochong:id/tv_license_plate"}
    info: [debug] Waiting up to 15000ms for condition
    info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.sdwx.ebochong:id/tv_license_plate","context":"","multiple":false}]
    info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.sdwx.ebochong:id/tv_license_plate","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.sdwx.ebochong:id/tv_license_plate using ID with the contextId: multiple: false
    info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.sdwx.ebochong:id/tv_license_plate]
    info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
    info: [debug] [BOOTSTRAP] [debug] Finding com.sdwx.ebochong:id/tv_license_plate using ID with the contextId: multiple: false
    info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.sdwx.ebochong:id/tv_license_plate]
    info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":7,"value":"No element found"}
    info: [debug] Waited for 1730ms so far
    info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.sdwx.ebochong:id/tv_license_plate","context":"","multiple":false}]
    info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.sdwx.ebochong:id/tv_license_plate","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.sdwx.ebochong:id/tv_license_plate using ID with the contextId: multiple: false
    info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.sdwx.ebochong:id/tv_license_plate]
    info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
    info: [debug] [BOOTSTRAP] [debug] Finding com.sdwx.ebochong:id/tv_license_plate using ID with the contextId: multiple: false
    info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.sdwx.ebochong:id/tv_license_plate]
    info: [debug] Waited for 2378ms so far
    info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":7,"value":"No element found"}
    info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.sdwx.ebochong:id/tv_license_plate","context":"","multiple":false}]
    info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.sdwx.ebochong:id/tv_license_plate","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.sdwx.ebochong:id/tv_license_plate using ID with the contextId: multiple: false
    info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.sdwx.ebochong:id/tv_license_plate]
    info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
    info: [debug] [BOOTSTRAP] [debug] Finding com.sdwx.ebochong:id/tv_license_plate using ID with the contextId: multiple: false
    info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.sdwx.ebochong:id/tv_license_plate]
    info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":7,"value":"No element found"}
    info: [debug] Waited for 2996ms so far
    info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.sdwx.ebochong:id/tv_license_plate","context":"","multiple":false}]
    info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.sdwx.ebochong:id/tv_license_plate","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.sdwx.ebochong:id/tv_license_plate using ID with the contextId: multiple: false
    info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.sdwx.ebochong:id/tv_license_plate]
    info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
    info: [debug] [BOOTSTRAP] [debug] Finding com.sdwx.ebochong:id/tv_license_plate using ID with the contextId: multiple: false
    info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.sdwx.ebochong:id/tv_license_plate]
    info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":7,"value":"No element found"}
    info: [debug] Waited for 3572ms so far
    info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.sdwx.ebochong:id/tv_license_plate","context":"","multiple":false}]
    info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.sdwx.ebochong:id/tv_license_plate","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.sdwx.ebochong:id/tv_license_plate using ID with the contextId: multiple: false
    info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.sdwx.ebochong:id/tv_license_plate]
    info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
    info: [debug] [BOOTSTRAP] [debug] Finding com.sdwx.ebochong:id/tv_license_plate using ID with the contextId: multiple: false
    info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.sdwx.ebochong:id/tv_license_plate]
    info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":7,"value":"No element found"}
    info: [debug] Waited for 4090ms so far
    info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.sdwx.ebochong:id/tv_license_plate","context":"","multiple":false}]