“Gulir ke Elemen Python Selenium” 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

cara menggulir di 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)
Dangerous Dog

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 ke bawah selenium python

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

Jawaban yang mirip dengan “Gulir ke Elemen Python Selenium”

Pertanyaan yang mirip dengan “Gulir ke Elemen Python Selenium”

Lebih banyak jawaban terkait untuk “Gulir ke Elemen Python Selenium” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya