click here for image description
Hello, I am currently working on automating the process of clicking follow buttons using Java. However, I'm encountering difficulties when trying to use JavascriptExecutor within a for loop. Below is the code snippet I'm working with:
List<WebElement> clickOnFollowButton = driver.findElements(By.xpath("//button[contains(text(),'Follow')]"));
for (int i = 0; i < clickOnFollowButton.size(); i++) {
driver.findElements(By.xpath("//button[contains(text(),'Follow')]")).get(i).click();
((JavascriptExecutor)driver).executeScript("arguments[0].scrollIntoView();", clickOnFollowButton);
}
I would greatly appreciate any assistance you can provide. Thank you.