How to scroll page with selenium

后端 未结 4 1951
深忆病人
深忆病人 2021-02-04 12:34

I am using FirefoxDriver webdriver. The page that loads in Firefox window is a large page and I want to scroll that page using selenium.

I want to know how this can be d

相关标签:
4条回答
  • 2021-02-04 12:55

    Use this code to scroll single page down

    Actions actions = new Actions(driver);
    actions.sendKeys(Keys.BACK_SPACE).perform();
    
    0 讨论(0)
  • 2021-02-04 13:03

    I think you should do something like

    driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
    

    Good Luck.

    0 讨论(0)
  • 2021-02-04 13:16
    page.driver.browser.mouse.move_to( find("element").native,100,100)
    
    0 讨论(0)
  • 2021-02-04 13:20

    If you want to scroll on the firefox window using selenium webdriver, one of the way is to use javaScript in the java code, The javeScript code to scroll down is as follows:

    WebDriver driver = new FirefoxDriver();
    JavascriptExecutor js = (JavascriptExecutor)driver;
    js.executeScript("window.scrollTo(0,Math.max(document.documentElement.scrollHeight," + "document.body.scrollHeight,document.documentElement.clientHeight));");
    
    0 讨论(0)
提交回复
热议问题