Delete all text in a browser text input box

Post your questions and help other users.

Moderator: Martin

Post Reply
EBen
Posts: 13
Joined: 27 Aug 2014 08:06

Delete all text in a browser text input box

Post by EBen » 05 Dec 2014 07:38

I try to input some text into a text box on a website using the automagic action "control UI". I managed to put in the text with commands
focus(x,y) and sendText(), but sometimes there is already some text in the box before, which I first must delete, in order to put in my new text into the emptied text box. I insert sleep(1000) between all commands. I tried with cut(x,y), but no joy. Also sendText("\b") does not work. I am not sure if \b is the correct escape sequence for a backslash. Where do I find a table of automagic escape sequences?

Thanks for your help.

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Delete all text in a browser text input box

Post by Martin » 05 Dec 2014 10:03

Hi,

sendText does not allow to enter backspace characters. sendKey(67); or sendKey("DEL"); in a loop should work.
It should also be possible to either use function setText("abc") to replace the text in the field or by using selectAll() to select the text in the input field first and then sendText("abc") to replace the selection with your new text.
On Android 5 you could also use function setText2 to enter the text without activating the Automagic "keyboard".

Regards,
Martin

EBen
Posts: 13
Joined: 27 Aug 2014 08:06

Re: Delete all text in a browser text input box

Post by EBen » 07 Dec 2014 19:43

Hi Martin,
thanks for the hints. Unfortunately, they all don't help.
SetText does not simply set the text, but rather adds it to the rest which has already been in the box. It is the same with SelectAll() followed by SendText. SelectText does not select the text, but just jumps to the first position in the text box. Maybe it doesn't work on my device? It is a Samsung I9505 with CM11 M12. Any ideas?

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Delete all text in a browser text input box

Post by Martin » 08 Dec 2014 17:27

Hi,

Strange, maybe it's also a special 'feature' of the web browser or this text box. Browsers sometimes use their own types of text boxes that don't properly support all input features. I have to admit that I only tested using a regular text field in a regular app. This also works on CM11 in a quick test.
What site and what browser are you using?
Maybe you have to resort to the workaround and send some delete keys: for(i in [1 to 100]) {sendKey("DEL");}

Regards,
Martin

EBen
Posts: 13
Joined: 27 Aug 2014 08:06

Re: Delete all text in a browser text input box

Post by EBen » 10 Dec 2014 07:48

Hi Martin, aus irgendeinem Grund funktioniert bei mir KEINER der Ansätze, auch nicht die aus den PNs. Habe es auch noch erfolglos mit longclick(x,y) probiert. Mein Workaround: Per control UI mit click auf Einstellungsmenu, aktualisieren die Seite aktualisieren, dann sind die Textfelder leer. Ideal wäre, wenn man bei der load URL in browser action optional ein Neuladen erzwingen könnte.
Danke nochmals!

Post Reply