Scroll Element into View with Selenium

前端 未结 30 2357
时光说笑
时光说笑 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 09:13

    Something that worked for me was to use the Browser.MoveMouseToElement method on an element at the bottom of the browser window. Miraculously it worked in Internet Explorer, Firefox, and Chrome.

    I chose this over the JavaScript injection technique just because it felt less hacky.

提交回复
热议问题