Scroll up and down to get Element into View with Selenium Python

后端 未结 6 1623
梦毁少年i
梦毁少年i 2021-01-05 19:10

I need to be able to scroll up and after that down to find some element with Selenium.
I already saw many questions and answers, the main idea I found is self.web_

6条回答
  •  既然无缘
    2021-01-05 19:32

    You can do it with also getBoundingClientRect() and scrollTo()

    self.web_driver.execute_script("coordinates = arguments[0].getBoundingClientRect();scrollTo(coordinates.x,coordinates.y);", element)
    

    I tested and it goes up and down.

提交回复
热议问题