Selenium - send keys - which item should i use

I am trying to scroll to the bottom of the page. I was asked, 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 cannot figure out which shoul element I am using. I tried to put an instance of webdriver instead of an element, but it didn't work. Do I need something like the current window item?

Do you have any ideas?

+3


source to share


3 answers


This should be enough to scroll down the page



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)

      

+4


source


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.

+2


source


Simple javascript should suffice. Python syntax

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

      

+2


source







All Articles