selenium dynamic growing table(硒动态生长表)
问题描述
我在使用 selenium 处理动态增长表时遇到了一些麻烦.快速总结一下,在我的网络应用程序中,我有一个包含 30 个项目的表格,但它只显示前 20 个项目,我们必须向下滚动才能显示其余项目.而且我不知道如何在不向下滚动的情况下获取第 26 个(例如)项目.
I have some troubles to handle dynamic growing table with selenium. To sum up quickly, on my web app I have a table with 30 items but it only displays the twenty first items and we have to scroll down to display the rest. And I don't know how to get the 26th (for example) items without scrolling down.
我的 HTML:
<table id="tableID" tabindex="0" aria-multiselectable="true" role="grid">
<thead>
<tbody id="tableID-tblBody">
<tr id="item1" role="row" tabindex="-1">
<tr id="item2" role="row" tabindex="-1">
[... 17 more]
<tr id="item20" role="row" tabindex="-1">
</tbody>
</table>
滚动后:
<table id="tableID" tabindex="0" aria-multiselectable="true" role="grid">
<thead>
<tbody id="tableID-tblBody">
<tr id="item1" role="row" tabindex="-1">
<tr id="item2" role="row" tabindex="-1">
[... 27 more]
<tr id="item30" role="row" tabindex="-1">
</tbody>
</table>
如果有人可以帮助我,那就太好了^^
谢谢!
If someone could help me it would be great ^^
Thanks!
推荐答案
我会滚动到表中最后一行的视图(如果需要多次,直到获得所需的行数).为此,我将通过 executeScript() 使用 scrollIntoView():
JavascriptExecutor jse = (JavascriptExecutor) driver;
jse.executeScript("arguments[0].scrollIntoView();", element);
其中元素:
WebElement element = driver.findElements(By.xpath("//table[@id = 'tableID']//tr[last()]")).
这篇关于硒动态生长表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:硒动态生长表
基础教程推荐
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 如何对 Java Hashmap 中的值求和 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
