Calum
Calum

Reputation: 2130

How can selenium enter multiple chars at once?

My question concerns a text input box that evaluates the input after each char is entered.

In selenium,

element.sendKeys(string);

sends each char in the string as an individual key press (which makes sense). But in real life i can push a couple keys quick enough that the input box takes in 2+ chars at once.

How can I simulate this with selenium?

Do i need to do a 'copy/paste' or is there another way?

Upvotes: 1

Views: 228

Answers (1)

Werewolfas
Werewolfas

Reputation: 46

If you use Java then you can try to use "Paste" way

setClipboardContents(longText);
textarea.sendKeys(Keys.CONTROL + "v");

If C# you can try to use:

Clipboard.SetText(longText);
textarea.sendKeys(Keys.CONTROL + "v");

Upvotes: 2

Related Questions