Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

scroll to element python selenium

from selenium.webdriver.common.action_chains import ActionChains

element = driver.find_element_by_id("my-id")

actions = ActionChains(driver)
actions.move_to_element(element).perform()
Comment

how to scroll by in selenium python

   for i in range(20): # adjust integer value for need
       # you can change right side number for scroll convenience or destination 
       driver.execute_script("window.scrollBy(0, 250)")
       # you can change time integer to float or remove
       time.sleep(1)
Comment

scroll down selenium python

browser.execute_script("window.scrollTo(0,document.body.scrollHeight)")
Comment

scroll to element selenium python

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver_service = Service(executable_path="C:/selenium_browser_driver/chromedriver.exe")
driver = webdriver.Chrome(service=driver_service)
site = 'https://example.com'
driver.get(site)  # opens the site in browser

element = WebDriverWait(driver, 20).until(
            EC.presence_of_element_located((By.XPATH, '//div[@class="perf-chart-container"]')))
#element = driver.find_element(By.XPATH, '//div[@class="perf-chart-container"]')
desired_y = (element.size['height'] / 2) + element.location['y']
current_y = (driver.execute_script('return window.innerHeight') / 2) + driver.execute_script('return window.pageYOffset')
scroll_y_by = desired_y - current_y
driver.execute_script("window.scrollBy(0, arguments[0]);", scroll_y_by)
Comment

PREVIOUS NEXT
Code Example
Python :: pd.set_option show all rows 
Python :: set index to column pandas 
Python :: cv2 save video mp4 
Python :: python os checj if path exsis 
Python :: create an array with same value python 
Python :: dollar 
Python :: copy text python 
Python :: order by listview django 
Python :: create dataframe pyspark 
Python :: python read gzipped file 
Python :: ImportError: No module named django.core.wsgi 
Python :: discord.py add reaction to message 
Python :: python first day of last month 
Python :: python read file csv 
Python :: runserver manage.py 
Python :: pandas return first row 
Python :: pip neat 
Python :: remove multiple space python 
Python :: pandas convert date to string 
Python :: tracking mouse position tkinter python 
Python :: isinstance numpy array 
Python :: python get int from string 
Python :: send embed discord.py 
Python :: how to blit text in pygame 
Python :: python f string thousand separator 
Python :: csrf token exempt django 
Python :: reduced fraction python 
Python :: selenium current url 
Python :: python os get output 
Python :: remove title bar in tkinter 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =