出现元素不在可视区域:
0、元素不可见
1、元素被遮挡
1、其他的弹框遮挡
2、因滚动条滚动而不在可视区域内
3、......等
本次主要针对1-2的情况:
1、获取元素的位置
2、获取网页水平导航条的位置
3、垂直滚动条滚动距离=元素.pos-y - 水平导航条.pos.y
4、将滚动条置顶
5、判断元素.pos-x是不是小于0,,成立则水平滚动条滚动-(元素.pos-x), 垂直滚动条则滚动垂直滚动条滚动距离
Scroll Element In View
[Arguments] ${locator}
# window.scrollY 与当前元素的高度大小比较
${height_top}= Get Vertical Position ${LQuanping}
${height}= Get Vertical Position ${locator}
${Horizontal}= Get Horizontal Position ${locator}
#滚动
Execute Javascript window.scrollBy(0,-120000);
${height1}= Evaluate ${height}-${height_top}
run keyword if ${Horizontal} < 0 Execute Javascript window.scrollBy(-${Horizontal},${height1});
... ELSE Execute Javascript window.scrollBy(0,${height1});
浙公网安备 33010602011771号