javascript error: arguments[0].scrollIntoView is not a function using selenium on python

后端 未结 2 1721
南笙
南笙 2021-01-28 14:10

I\'m using Selenium on python and I would like to scroll to an element to click on it. Everywhere I see that the rigth things to do to go directly to the element is to use :

2条回答
  •  一个人的身影
    2021-01-28 14:50

    scrollIntoView() is part of the DOM API and you need to run it on an WebElement but not on a List of WebElement(s).

    You need to change find_element(s) to find_element:

    element = driver.find_element_by_class_name('dg-button')
    driver.execute_script("return arguments[0].scrollIntoView();", element)
    

提交回复
热议问题