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

selenium scroll to element

element = driver.find_element(By.XPATH, "Whatever xpath you want")
driver.execute_script("return arguments[0].scrollIntoView();", element)
Comment

selenium scroll to element python

# this scrolls untill the element is in the middle of the page
element = driver.find_element_by_id("my-id")
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

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 :: reset index 
Python :: python pil bytes to image 
Python :: drop rows with certain values pandas 
Python :: char list 
Python :: django populate choice field from database 
Python :: rotational list python 
Python :: python print object 
Python :: how to filter mask results in python cv2 
Python :: create jwt token python 
Python :: print progress without next line python 
Python :: how to move a column to last in pandas 
Python :: requests post with headers python 
Python :: show all rows with nan for a column value pandas 
Python :: mongodb check if substring in string 
Python :: python poner en mayusculas 
Python :: select columns from dataframe pandas 
Python :: python count lines in string 
Python :: keras read image 
Python :: except index out of range python 
Python :: decode base64 with python 
Python :: how to know if the numbers is par in python 
Python :: ec2 upgrade python 3.7 to 3.8 
Python :: python exceute 60 records per minute counter 
Python :: model.predict([x_test]) error 
Python :: how to auto update chromedriver selenium python 
Python :: download a file from kaggle notebook 
Python :: colab kaggle dataset 
Python :: Set column as index with pandas 
Python :: run 2 loops simultaneously python 
Python :: python filter a dictionary 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =