水平滚动表格

时间:2020-10-27 15:43:15

标签: ruby watir

我有这张桌子

enter image description here

我必须水平滚动才能单击按钮,如下所示

enter image description here

这是此元素的HTML代码

<div tabindex="-1" class="v-grid-scroller v-grid-scroller-horizontal" style="padding-bottom: 17px; height: 0px; width: 1036px; left: 0px; overflow-x: scroll;"><div style="height: 17px; width: 1566.09px;"></div></div>

我可以使用WATIR进行水平滚动吗?

1 个答案:

答案 0 :(得分:0)

类似于scrolling vertically,您将需要使用JavaScript水平滚动元素。这是通过设置scrollLeft属性来完成的:

# Get the element that has the overflow property
div = browser.div                                                                                      

# Scroll to a specific point
div.execute_script('arguments[0].scrollLeft = 100;', div) 

# Scroll right a certain amount
div.execute_script('arguments[0].scrollLeft += 50;', div)