2

On my test, I want to simulate with Selenium, the "top arrow" increment. For this, I've do this to begin : myVar.sendKeys(Keys.ARROW_UP); Before the increment, the value is 0. After, the value is 1. I want to increment up 10, please. I don't want write my line code 10 times.

1
  • 3
    What's stopping you from using a loop? Commented Jun 30, 2017 at 13:15

1 Answer 1

2

As Edsger Dijkstra once said:

"Two or more, use a for" - Edsger Dijkstra

So you can simply write a for loop over the function call:

for(int i = 0; i < 10; i++) {
    myVar.sendKeys(Keys.ARROW_UP);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.