delete random number of characters from textbox in selenium

  • 1 Replies
  • 1177 Views
delete random number of characters from textbox in selenium
« on: August 02, 2016, 18:52:13 pm »
I have a textbox to run tests on and i need to delete a random number of characters from the string
so if i have a string: "Hello world"

I would like to delete 2 or 3 of last characters

What is the best way to do this in selenium ?

Re: delete random number of characters from textbox in selenium
« Reply #1 on: August 07, 2016, 16:50:59 pm »
Just make a for loop with your random number and send backspace key to the element in question:

Code
for(int i = 0; I < random; i++) {
    element.sendKeys(Keys.BACK_SPACE);
}

 

Sitemap 1 2 3 4 5 6 7 8