gpt4 book ai didi

java - 如何使用 java 集合收集表中的特定行 id - webdriver

转载 作者:太空宇宙 更新时间:2023-11-04 06:29:52 25 4
gpt4 key购买 nike

HTML代码

<table id="tblRenewalsStatus" class="bor-bot" width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr id="trVerifyPayment">
<tr id="trAssignAgent">
<tr id="trAssigned">
<tr id="trPayAgent" style="display: none;">
<tr id="trPaymentVerificationPending" style="display: none;">
<tr id="trInProgress" style="display: none;">
<tr id="trPayAgentCommission">
<tr id="trPaymentVerificationPendingCommission">
<tr id="trCompleted">
<tr id="trCancelled">
</tbody>
</table>

我想收集所有没有样式属性值的 tr id,

预期输出,

“trVerifyPayment”,“trAssignAgent”,“trAssigned”,trPayAgentCommission”,“trPaymentVerificationPendingCommission”,“trCompleted”,“trCancelled”

最佳答案

List<WebElement> id_elements = driver.findElements(By.xpath("//table[@id='tblRenewalsStatus']//tr"));

ArrayList<String> tr_id= new ArrayList<String>();
for(WebElement ele : id_elements)
{

String style = ele.getAttribute("style");

if(style==null||style=="")
{
String id=ele.getAttribute("id");
tr_id.add(id);
}
}

System.out.println(tr_id);

关于java - 如何使用 java 集合收集表中的特定行 id - webdriver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26273252/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com