“selenium gulir ke elemen python” Kode Jawaban

Gulir ke Elemen 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()
Happy Hawk

selenium gulir ke elemen 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)
Helpless Hummingbird

Gulir selenium ke elemen

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

Jawaban yang mirip dengan “selenium gulir ke elemen python”

Pertanyaan yang mirip dengan “selenium gulir ke elemen python”

Lebih banyak jawaban terkait untuk “selenium gulir ke elemen python” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya