automate click till the end of carousel using selenium webdriver

4.4k views Asked by At

I want to click on next arrow of a carousel till the end of loop. now how do i click constantly on the next arrow using selenium webdriver ?? I did for-loop in the click but its not working. This is the basic code for the element and click.

element = driver.findElement(By.xpath(".//*[@id='hp_category_tab_electronics_0-content']/div[1]/div/div/a[2]"));
element.click();

so in short i want to click on next arrow button for like 5 times before the end of products is encountered.

1

There are 1 answers

1
Arpan Buch On BEST ANSWER
element = driver.findElement(By.xpath(".//*[@id='hp_category_tab_electronics_0-content']/div[1]/div/div/a[2]"));
element.click();
for(int i=0;i<4;i++);{
        Thread.sleep(500);
        element.click();
    }

I found the code actually i was not using thread.sleep(); before.