Using the delete command

I’m trying to get my head around the delete command and I’ve read through all the relevant support on the below page without any luck:

I should say that I’m a beginner, so please forgive me if I’ve missed anything obvious.

I’m using an Android device and I just want to delete all the characters that are in a box. I’ve managed to put the cursor in it and have tried a large range of variations on the delete command with no luck.

Any ideas are welcome! Thanks


It depends what type of text you want to delete.
For example
If you have a text with no spaces in between then try with DoubleClick() which will highlight the whole text.
If you have a text which also includes spaces in between (such as “AB CD EF”) then try with Typetext ControlKey, “a”.

Let me now if this works for you.

The delete command is for deleting things from strings in your script, not from the SUT. So for example, you could say:

put "the quick brown fox jumped over the lazy dog" into myvar
delete "the" from myvar
put myvar // outputs " quick brown fox jumped over  lazy dog"

If you want to delete things on the SUT, then you have to write a script that deletes things the same way a user would, for example:

click "textField"
typeText controlKey, "a" // select all
typeText deleteKey // delete the text

You need to remember that eggPlant is a virtual user and it can only do what a user can do. If you could delete text through some non-UI interaction directly with the machine, then eggPlant probably could, but you have to select the text and press delete, so that’s how eggPlant has to do it.

Hi guys, thanks for your replies and apologies for the late reply.

I’m not sure but I think I need to emphasise that my System Under Test is an Android device?

I’ve tried both the commands suggested - DoubleClick, and the controlKey, “a” and none of them seem to select the text.

Thank you again for your help and I look forward to your responses!

How do you select the text on the Android as a user? You will need your script to do the same thing. If you normally do it by pressing and dragging, then you will use the drag and drop commands. If a press and hold to access a menu, then you would use:

moveTo "textfield"
mouseButtonDown 1
WaitFor "select"
click foundImageLocation()

Thank you for your reply Matt.

Unfortunately the app I’m testing does not use the android cut/copy/paste system so I can’t use the tap and hold to select all function. It also doesn’t support the drag to select function as there’s very few points where text is required to be entered.

The field in question has a limited amount of characters in so I ended up just pressing the backspace key 16 times.

Thanks again for your help.