This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.

Hi, I notice that method clear() on WebElement with type password textfield is not immediately emptying the field. This is not happened to the ordinary text field. Sometimes the element successfully cleared on 20th .clear() method, sometimes on the 5th, sometimes on the 30th, and sometimes need more that that, it is unpredictable.
Another problem is, unlike ordinary text field, I cannot use getText() method to retrieve the unmasked value on Password text field. Therefore, workaround like checking on length of the password text field, when it is empty, then continue to the next action become useless.

Here is the log taken from Appium on unsuccessfull clear() method

info: <-- POST /wd/hub/session/f1e4cf6a-e4d1-4eda-8e4d-1cc3d3d6af3b/element/3/clear 200 1846.285 ms - 76 {"status":0,"value":true,"sessionId":"f1e4cf6a-e4d1-4eda-8e4d-1cc3d3d6af3b"}
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":true}
info: --> POST /wd/hub/session/f1e4cf6a-e4d1-4eda-8e4d-1cc3d3d6af3b/element/3/clear {"id":"3"}
info: [debug] Pushing command to appium work queue: ["element:clear",{"elementId":"3"}]

info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:clear","params":{"elementId":"3"}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: clear
info: [debug] [BOOTSTRAP] [debug] Attempting to clear using UiObject.clearText().

info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":true}

info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"f1e4cf6a-e4d1-4eda-8e4d-1cc3d3d6af3b"}

I have tried this (https://discuss.appium.io/t/how-to-clear-a-pre-filled-text-field-android/1022), which suggest to send AndroidKeyCode.KEYCODE_DEL, still not deleting / emptying the pre-filled password field as I expected

Do you have any suggestion for this kind of issue?

  • created

    Feb '16
  • last reply

    Mar '18
  • 1

    reply

  • 806

    views

  • 2

    users

2 years later

I got the same problem with AndroidDriver. I’ve tried

txtElement.clear();

as well as

driver.pressKeyCode(28);

The test does not fail, but the emulator does not clear out the editText field.