Scroll Element into View with Selenium

前端 未结 30 2808
时光说笑
时光说笑 2020-11-22 08:31

Is there any way in either Selenium 1.x or 2.x to scroll the browser window so that a particular element identified by an XPath is in view of the browser? There is a focus m

30条回答
  •  暖寄归人
    2020-11-22 08:59

    The Ruby script for scrolling an element into view is as below.

    $driver.execute_script("arguments[0].scrollIntoView(true);", element)
    sleep(3)
    element.click
    

提交回复
热议问题