TestProject Forum
Powered by leading experts in the test automation community

Use Action 'Send Keys' to type chars


I can use the Action “Send Keys” and enter for example “ENTER” or “NUMPAD5” to simulate the press on a key without choosing an element first (that’s important in my situation).

Can I also type text (simulate pressing the letters on the keyboard) with this action?


I’m looking forward to some help :slight_smile:

Best Regards,

Hi Dennis, thanks for reaching out in the forum.

The send keys action only supports the keys listed in the URL given.
Type text is an element action, means you must have some element for that to work.
You can do some mix up with those if you need to achieve something.

May I ask what is your use case?

I’m clicking on a button then I can start (without clicking into the input field) typing a name for that field and confirm the name with pressing enter.

The reason I don’t want to click into that input field is, that its attributes and place in the DOM are generated dynamically. So when I’m replaying the test, its not working anymore.

You can solve the issue with some dynamic xpath.
You can select the input field with the static parts of the element using the right xpath or JavaScript functions.

Thanks for the answer.
But I still have to replace the dynamic part (for example a number which is newly generated every test run) by hand everytime before I start the test.

Or is there something I dont understand about dynamic xPaths?

We allow using test parameters when creating xpaths to create dynamic ones that can change with your test.
If it is possible for you to extract that randomly generated value from somewhere before reaching the test step that requires it, you will be able to use it there.
For example:

Consider changing the way you search for this element if possible.