“SELENIUM SCROLL do Element Python” Kod odpowiedzi

Przewiń do elementu Pythona selenu

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 SCROLL do 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)
Helpless Hummingbird

SELENIUM SCROLL do Element

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

Odpowiedzi podobne do “SELENIUM SCROLL do Element Python”

Pytania podobne do “SELENIUM SCROLL do Element Python”

Więcej pokrewnych odpowiedzi na “SELENIUM SCROLL do Element Python” w Python

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu