Could you please tell me how to send multiple whitespace / blank space using sendkeys or something similar. I am trying to test acceptance of creating username using multiple withespaces between other characters (like say "user name"). I was not successfull using a string, using sendkeys "user name" or using sendkeys(Keys.SPACE) multiple times. It always reduces to one single whitespace. Thank you very much.
Asked
Active
Viewed 357 times
-1
-
Does my answer solves your problem? – Prophet Jul 30 '21 at 07:40
1 Answers
0
Try sending it with sendKeys()
method using Actions.
public void sendTextAction(By locator, String text){
Actions action = new Actions(driver);
clickVisible(locator);
action.sendKeys(text).build().perform();
}
In case this still will not work try involving this method several times i.e. to send "user name" try this:
sendTextAction(elementLocator,"user");
sendTextAction(elementLocator," ");
sendTextAction(elementLocator," ");
sendTextAction(elementLocator," ");
sendTextAction(elementLocator,"name");
but first try this
sendTextAction(elementLocator,"user name");

Prophet
- 32,350
- 22
- 54
- 79