Java - SendKeys multiple times (Keys.ARROW_RIGHT)

86 Views Asked by At

Hi people: I'm trying o automate (Selenium with Java) a method that moves from a row to another (10 times) with the sendKeys. I tried with for cicle, but it's not working:

    public void moveToNextRow() {
       for (int i = 0; i < 10; i++) {
       this.myPage.FirstRow().sendKeys(Keys.ARROW_RIGHT);
    }

The other way that I tried was with IntStream, but also it's not working.

    public void moveToNextRow() {
       IntStream.iterate(1, n -> n + 1).limit(10).forEach(number -> 
       this.myPage.FirstRow().sendKeys(Keys.ARROW_RIGHT));
    }

Can anybody help me with that?

1

There are 1 best solutions below

0
Vitor Santos On
  • Maybe you should to include some delay in your code like
    TimeUnit.SECONDS.sleep(1);

or

{
    try
    {
        Thread.sleep(ms);
    }
    catch(InterruptedException ex)
    {
        Thread.currentThread().interrupt();
    }
}

Try increasing step by step, starting por 0.1 s