簡體   English   中英

我需要向下滾動,直到使用硒Webdriver在電子商務網站中完成搜索結果為止

[英]I need to scroll down until the search result complete in e-commerce website using selenium webdriver

我想向下滾動頁面的底部

預期步驟:

  1. 打開應用程序網站(www.jabong.com)
  2. 我在搜索框中搜索男士手表
  3. 頁面將給出搜索結果。 在這里,我需要向下滾動頁面,直到頁面完成搜索結果為止。

我希望理解我的問題。 我嘗試了下面的代碼使用硒向下滾動

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM