【发布时间】:2018-01-31 11:24:19
【问题描述】:
我不是以英语为母语的人,对不起我的英语。 :)
我正在使用 Selenium Webdriver + Python。我的页面上有一个自定义滚动条。
<div class="k-scrollbar k-scrollbar-vertical" style="width: 18px;"><div style="width:1px;height:1102px"></div></div>
<div style="width:1px;height:1102px"></div>
这个滚动条的EV有方法“滚动”,代码是:
function updateGridScrollInState() {
if (typeof window.GridProfile_Grid === 'object') {
window.GridProfile.ScrollY = window.GridProfile_Grid.data("kendoGrid").virtualScrollable.verticalScrollbar.scrollTop();
}
}
我可以使用它进行操作,我知道滚动条的定位器,但我不明白如何通过 driver.execute_script(some_script) 使用 javascript 将特定元素滚动到网格中。
我需要移动到位于视口之外的元素:它是网格,网格有 33 行,但只显示 22 行,如果我向下滚动则显示其他 11 行。我试图拖放这个滚动条:
ActionChains(driver).drag_and_drop(my_custom_scrollbar, list_of_grid_rows[30]).perform()
但我得到了例外:
selenium.common.exceptions.MoveTargetOutOfBoundsException: Message: (1015, 1242.699951171875) is out of bounds of viewport width (1920) and height (968)
我想我可以在 list_of_grid_rows[index] 不显示的情况下进行拖放。但是我怎样才能得到这个结果呢?也许我必须以某种方式使用滚动条的高度值?
谢谢你的提前!
【问题讨论】:
标签: javascript python selenium