How to clear Prefilled text of a textbox in mac

Prefilled text of a textbox is not getting cleared in Mac. Is there a workaround for it.

We are seeing the same sort of thing for Android. We are using Appium 1.2.2.

It’s odd, because the release notes from version 1.2.2 states that there was a fix put in place for sendKeys

correct sendKeys behavior not to clear text before sending keys

So, if I am interpreting this correctly, when calling sendKeys from 1.2.2, the text will no longer be cleared??

You’re correct https://github.com/appium/appium/issues/3347

Thanks for the feedback. It was very helpful

Sorry I actually didn’t see the original post (late and whatnot)

I read the above snippet you grabbed from the release notes as:

“We have corrected the sendKeys behavior so that it does not clear pre-populated text before sending keys”

I tried to give you a reference to the (github issue) that jlipps created, which outlines the requirement to append to existing text instead of internally doing textfield.clear() before each textfield.sendKeys()

Basically, previous versions of Appium have prefixed every sendKeys call with clear. That was determined to be incorrect behavior.

Two workarounds for this new behavior are:
textfield.clear() in front of all of the textfield.sendKeys('blah') calls you were relying on before to do both the clearing and the value setting.

Probably a better solution since it is recommended for iOS due to Instrument’s flakiness surrounding sendKeys is to use .setValue('blah') on the textfield.*

* If you are using Java, I believe setValue is broken and you can try setValueImmediate('blah'))

@JessicaSachs

Ok, this makes more sense with what we’re experiencing.

In prior versions of Appium, when we used sendKeys() [Java version], the textfield was cleared and our data was entered into the field. Now (as of 1.2.2), when we run our tests using sendKeys(), the text is appended on to pre-existing text – not the behavior we want. We will investigate using setValueImmediate() instead of sendKeys(), along with the clear() method.

Thanks for the detailed explanation.

I did not see the method setValueImmediate in the driver as well as in the webelement. Let me know if you find a way to use it.

I believe if you just do setValue('blah') it will show “Not Implemented yet. Contribute to Appium.”

But I see it used in tests here. I don’t do Appium development in Java so I don’t really have an environment setup to test. You may be stuck doing .clear() and .sendKeys() in Java for now.

Ah! Any way it’s a good info. Good to know. Hopefully it will get fixed in next release

In Java, a MobileElement has the setValue method available and it works. You may have to cast your WebElement to a MobileElement.

2 Likes

MobileElement is not working for me. My test is ending abruptly when it reaches the mobile element statement

setValue is only for iOS. Maybe that’s causing the confusion.

OK. IOS is working fine just the android in MAC couldn’t able to proceed further

Hi,
I am facing similar issue while using Mac +iPod
i am doing setValue on a UIATextField

(using appium-java client 2.1)

It reaches till the text box and pauses indefinitely
server log

info: [debug] Waiting up to 0ms for condition

info: [debug] Pushing command to appium work queue: "au.getElementByType('UIATextField')"

info: [debug] Sending command to instruments: au.getElementByType('UIATextField')

info: [debug] [INST] 2014-12-15 06:06:19 +0000 Debug: Got new command 34 from instruments: au.getElementByType('UIATextField')

info: [debug] [INST] 2014-12-15 06:06:19 +0000 Debug: evaluating au.getElementByType('UIATextField')

info: [debug] [INST] 2014-12-15 06:06:20 +0000 Debug: evaluation finished

info: [debug] [INST] 2014-12-15 06:06:20 +0000 Debug: responding with:

info: [debug] [INST] 2014-12-15 06:06:20 +0000 Debug: Running system command #35: /usr/local/bin/node /usr/local/lib/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":{"ELEMENT":"0"}}...

info: [debug] Socket data received (38 bytes)

info: [debug] Socket data being routed.

info: [debug] Got result from instruments: {"status":0,"value":{"ELEMENT":"0"}}

info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"0"},"sessionId":"dde6d442-b0da-4723-ab72-adeed61bb44b"}

info: <-- POST /wd/hub/session/dde6d442-b0da-4723-ab72-adeed61bb44b/element 200 1334.394 ms - 87 {"status":0,"value":{"ELEMENT":"0"},"sessionId":"dde6d442-b0da-4723-ab72-adeed61bb44b"}

info: --> POST /wd/hub/session/dde6d442-b0da-4723-ab72-adeed61bb44b/appium/element/0/value {"id":"0","value":"mine"}

info: [debug] Pushing command to appium work queue: "au.getElement('0').setValue(‘mine')"

info: [debug] Sending command to instruments: au.getElement('0').setValue('mine')

info: [debug] [INST] 2014-12-15 06:06:24 +0000 Debug: Got new command 35 from instruments: au.getElement('0').setValue('mine')

info: [debug] [INST] 2014-12-15 06:06:24 +0000 Debug: evaluating au.getElement('0').setValue('mine')

info: [debug] [INST] 2014-12-15 06:06:24 +0000 Debug: target.frontMostApp().elements()[1].elements()[3].elements()[0].elements()[0].elements()[3].tap()

info: [debug] Didn't get a new command in 60 secs, shutting down...

info: Shutting down appium session

Is there any such known issues with appium-java client