如果这个问题有点模棱两可,我很抱歉。我注意到,如果Geb元素不在页面上,并且需要使用“内部”滚动条滚动,那么Geb元素就不会被滚动到视图中
所谓“内部”滚动条,我指的是嵌套在给定网页中的滚动条,与全局网页的滚动条分离。
我做过一些不同的手工滚动这些内部滚动条的方法,但是我想知道Geb是否提供了处理这些嵌套滚动条的功能。
下面是一个代码片段,演示如何处理查找给定行的操作:
class TabledModule extends Module {
static content = {
headers {$(By.xpath("//lane-group-header"))}
table {$(By.xpath("//div[@class=',y-class']"))}
}
Navigator getAllRows(){
return table.children()
}
Navigator getRow(String text){
return table.children().find{it.text().contains(text)}
}
Navigator getRow(int index){
return table.children()[index]
}
}
根据我的剧本:
getAllRows() //returns 50 which it should (only 20 are displayed)
def row = getRow(45) //returns a navigator as it should
row.click() //successfully clicks the correct row
def row2 = getRow("someString") //returns null when the row is off the page this is the problem and I'm wondering now if it is a bug, since getting the row by index seems to work fine.
对于这个模块,只显示50行中的20行来显示其他行,您必须滚动嵌套的滚动条才能找到它们。我要访问的行在列表的下方,因此需要滚动才能访问它。
有趣的是
getAllRows().size()
返回正确的行数:50,但是当我调用
getRow