我正在尝试使用 selenium 在我的 Ruby 脚本上使用 javascript 执行程序滚动到一个元素。但是,脚本会一直向下滚动页面并跳过该元素。因此不与元素交互。
滚动方式:
def scroll_into_view(element, locator=nil)
element = element.nil? ? find(locator) : element
@wd.execute_script('arguments[0].scrollIntoView(true);', element)
end
参考:
scroll_into_view(nil, gear_icon_span_locator)
您知道在 ruby 中滚动到元素的任何其他方法吗?
我已经尝试过动作构建器并实际上移动到一个元素,这似乎不起作用。