6

I'm trying to scroll at the bottom of the page. I was adviced, here on SO, to do this:

from selenium.webdriver.common.keys import Keys
element = driver.find_element_by_ ...
element.send_keys(Keys.CONTROL , Keys.END)

I can't figure out what element shoul I use. I was trying to put a webdriver instance instead of element but it did not work. I need something like current window element?

Have you any ideas?

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
Milano
  • 18,048
  • 37
  • 153
  • 353

3 Answers3

5

This should be enough to make scroll to page bottom

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver=webdriver.Chrome()
driver.get("site_name")
driver.find_element_by_xpath('//body').send_keys(Keys.CONTROL+Keys.END)
Andersson
  • 51,635
  • 17
  • 77
  • 129
3

A simple javascript should be sufficient as well. Python syntax

driver.execute_script("window.scrollTo(0,document.body.scrollHeight);")
Saifur
  • 16,081
  • 6
  • 49
  • 73
2
body = driver.find_element_by_xpath('/html/body')
body.click()
ActionChains(driver).key_down(Keys.COMMAND).send_keys(Keys.ARROW_DOWN).perform()

Looking at your previous question Link
This works on mac. Change the combo for Windows.

Community
  • 1
  • 1
Chandan Nayak
  • 10,117
  • 5
  • 26
  • 36