我需要将页面滚动到包含特定单词“加载更多”的特定 div,该单词在多个 div 中有多个文本。这是我的代码
List<WebElement> Loadmore = driver.findElements(By.xpath("//div[contains(text(), 'Load more')]"));
for(int i=0;i<Loadmore.size();i++)
{
String Loadmoreid = Loadmore.get(i).getAttribute("id");
WebElement Loadmoretxt = driver.findElement(By.xpath("//div[contains(@id, '"+Loadmoreid+"')]"));
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].scrollIntoView(true);", Loadmoretxt);
WebElement Loadmoreweb = driver.findElement(By.id(Loadmoreid));
Actions action = new Actions(driver);
action.moveToElement(Loadmoreweb).click().perform();
}