[英]I need to scroll down until the search result complete in e-commerce website using selenium webdriver
我想向下滾動頁面的底部
預期步驟:
我希望理解我的問題。 我嘗試了下面的代碼使用硒向下滾動
WebElement bottomButton = driver.findElement(By.xpath("//*[@id='catalog-product']/footer/button"));
WebDriverWait wait = new WebDriverWait(driver, 15);
do{
wait.until(ExpectedConditions.visibilityOf(bottomButton));
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("window.scrollBy(0,document.body.scrollHeight);");
bottomButton.click();
}while(!bottomButton.isDisplayed());
這對我有用:
js.executeScript("scroll(0,document.body.scrollHeight);");
我記得我嘗試過window.scrollBy,但是它也沒有用,也不知道為什么...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.