I have a question about scrolling to an element. I have this code below where I can filter out how to click an element based on its name:
public class LandingPage extends BasePage {
public LandingPage(WebDriver webDriver) {
super(webDriver);
}
By cardBody = By.className("card-body");
public void clickCard(String cardName) {
List<WebElement> elements = webDriver.findElements(cardBody);
click(
elements.stream()
.filter(element -> element.getText().equalsIgnoreCase(cardName))
.collect(Collectors.toList())
.get(0));
}
}
I want to do a similar thing but instead of clicking on an element, I want to scroll to the element. Does anyone know how to do this?