how to clear an input

Best practices, code snippets for common functionality, examples, and guidelines.
atntesting
Posts: 1
Joined: Wed Jul 19, 2017 9:07 am

how to clear an input

Post by atntesting » Wed Jul 19, 2017 9:11 am

Hi there,
I'm quite new with Ranorex.
Can you tell me how to clear an input?
Actually I have a login form and the login and password and pre-filled up. I need to clear those 2 inputs to input something new.
Thanks for your support.
Antoine.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: how to clear an input

Post by odklizec » Wed Jul 19, 2017 2:12 pm

Hi,

What I'm doing in such cases is sending Ctrl+A shortcut to given input, which basically selects the content of input and then the selection can be replaced with Key Sequence action. Hope this helps?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: how to clear an input

Post by Support Team » Wed Jul 19, 2017 8:19 pm

Hi Antoine,

Here are three different options for clearing an input field.
  • 1. Using {BACK} several times until the input is cleared. This is the most human like automation, but typically not recommended since the field length can vary.

    2. Using a CTRL+A Key Shortcut action to select all text prior to entering your own text. This is the best practice as it is still human like and safe to use on most input fields.

    3. Add a Set Value InnerText to nothing, or the text you need input. This is the not human like at all but get the job done efficiently. This action may not work on all input fields since some applications have specific key listeners and need to delete the text in a specific way. If this is the case, you will need to find the what your application is expecting, then have Ranorex duplicate this behavior.
Cheers,
Ned
You do not have the required permissions to view the files attached to this post.

User avatar
Stub
Posts: 515
Joined: Fri Jul 15, 2016 1:35 pm

Re: how to clear an input

Post by Stub » Thu Jul 20, 2017 8:03 am

On password fields I ended up right-clicking in a field and using Select All from the context menu before hitting Delete or Backspace or whatever it is I do. If Select All isn't enabled I know the field is empty.