java - 使用 Selenium JAVA 代码读取具有 <SPAN> 标签的列

标签 java selenium html-table automated-tests multiple-columns

我希望使用 Selenium Java 测试用例读取网页中每一行的“副本”和“队列大小”列。

期望的输出:

master1-dc 555555555
master2-dc  444444444444
master2-dr 333333333

网页截图如下:

我知道如何使用 selenium java 读取简单的列,但这对于标签来说是一个棘手的问题。

页面查看源码如下:enter image description here

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN" "http://validator.w3.org/sgml-lib/sp-1.3/pubtext/HTML32.dtd">
<HTML dir="LTR" lang="en"><BODY class="tundra" dir="LTR" onload="FormDataGp618f1eacJS().fInitEnable();" style="font-family:Arial, Helvetica, sans-serif;margin-left:0px;margin-top:0px;font-size:75%;"><FORM action="/IDSWebApp/WnServlet?WnRendererContainer=581&amp;WnProxy=empty&amp;WnRenderer=3692&amp;WnUserID=cn%3Droot%5B1577341867696%5D&amp;WnTransaction=Trans1995&amp;wti=Tca5b989e" class="frm1" dir="LTR" id="WFedd9c69a" method="POST" name="FormDataGp618f1eac" onsubmit="return FormDataGp618f1eacJS().fOneSubmit('WFedd9c69a');" secwindowsubmitflag="false" submitflag="false"><INPUT name="submitflag" type="hidden" value="false"><INPUT name="secWindowSubmitFlag" type="hidden" value="false"><INPUT name="wh" type="hidden" value="wh"><INPUT name="wa" type="hidden" value="wa"><INPUT name="treeFunc" type="hidden" value="treeFunc"><INPUT name="WnRendererContainer" type="hidden" value="581"><INPUT name="wti" type="hidden" value="Tca5b989e"><INPUT name="WnUserID" type="hidden" value="cn=root[1577341867696]"><INPUT name="WnRenderer" type="hidden" value="3692"><INPUT name="WnProxy" type="hidden" value="empty"><INPUT name="WnTransaction" type="hidden" value="Trans1995"><SPAN dir="LTR"><TABLE border="0" cellpadding="0" cellspacing="0" dir="LTR" style="background-color:#DADDEA;font-size:100%;" width="100%"><TR></TR></TABLE></TD></TR><TR><TD align="right" class="lyt2" colspan="3" valign="middle"><TABLE border="0" cellpadding="0" cellspacing="0" dir="LTR" style="background-color:#FFFFFF;font-size:100%;" width="100%"><TR><TD style="font-family:Arial, Helvetica, sans-serif;font-size:100%;"><IMG alt="" height="4" id="WIfc11ae1f6093_fc11ae1f" src="media/WnBlank.gif"></TD></TR></TABLE></TD></TR></TABLE></TD></TR></TABLE><IMG alt="" height="5" id="WIe973b8a67407_e973b8a6" src="http://10.9.45.89:1200/IDSWebApp/resources/media/WnBlank.gif" title=""><TABLE border="0" cellpadding="0" cellspacing="0" class="lyt1" dir="LTR"><TR><TD align="left" class="lyt2" rowspan="3" valign="top"><SPAN class="cont1" id="WCd4ae5d38"><SPAN class="cont1" id="WDWMDT5c8c1a2e"><SPAN dir="LTR"><A name="tableTop_5c8c1a2e"></A><IFRAME id="SaveFrame_5c8c1a2e" style="display:none" title="Save Frame"></IFRAME><TABLE border="0" cellpadding="0" cellspacing="0" dir="LTR" id="tbl_RepDetail_tableContainer" width="100%"><TBODY><TR><TD style="vertical-align:middle;"><SPAN class="cont1" id="tbl_RepDetail_toolBarRow"><SPAN class="cont1" id="WC6b3c8966"><A name="toolbarTop_6d0e9092"></A><TABLE border="0" cellpadding="0" cellspacing="0" dir="LTR" summary="" width="100%"><TBODY><TR</TR><TR><TD style="position:left" valign="top"><A id="anchor_Mc952a82d_WMB3cb22bac"><IMG alt="" border="0" height="1" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/o.gif" width="1"></A></TD></TR></TABLE></SPAN></SPAN></TD><TD style="vertical-align:middle;" valign="center">&nbsp;</TD><TD style="vertical-align:middle;" valign="center"></TD></TR></TABLE></TD><TD style="vertical-align:middle;"><IMG align="center" alt="" border="0" height="22" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/tbl37.gif" title="" width="15"></TD></TR></TABLE></TD></TR></TBODY></TD></TR></TABLE></TD></TR></TABLE></TD><TD class="tbr1" nowrap style="vertical-align:middle;" width="100%">&nbsp;</TD><TD class="tbr3" style="vertical-align:middle;"><IMG align="LEFT" alt="" border="0" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/tbl13.gif" width="12"></TD></TR></TABLE></TD></TR></TBODY></TABLE></SPAN></SPAN><DIV id="TD_5c8c1a2e" position="relative"><TABLE border="1" cellpadding="0" cellspacing="0" class="tbl1" datatable="1" id="tbl_RepDetail_headerRow" style="border-width:0px 1px 0px 1px;table-layout:fixed;font-size:100%;" width="100%"><TBODY id="H1B_5c8c1a2e"><TR><TH class="tcm1" id="WTCf65b9579" nowrap style="white-space:nowrap;" valign="top" width="-1"><TABLE border="0" cellpadding="0" cellspacing="0" class="headerTable__5c8c1a2e" style="table-layout:auto;font-size:100%;" width="100%"><TR class="tcm1"><TD nowrap style="overflow:hidden;text-overflow:ellipsis;vertical-align:middle;white-space:nowrap;" title="Select" valign="top"><SPAN id="WTCf65b9579_handle">&nbsp;Select&nbsp;</SPAN><INPUT name="client-reorder_5c8c1a2e" type="hidden" value="0"></TD><TD class="tcm1" onkeydown="if (event.keyCode == 13) { return tcDND(event, 1, 'WTCf65b9579', 'DD_5c8c1a2e'); }" onmousedown="return tcDND(event, 1, 'WTCf65b9579', 'DD_5c8c1a2e');" onmouseover="this.style.cursor = 'e-resize';" style="vertical-align:middle;" width="3px"><IMG align="center" alt="" border="0" height="" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/tbl13.gif" style="display:block;width:3px;" title="" width=""><INPUT name="client-resize_5c8c1a2e" type="hidden" value="-1"></TD></TR></TABLE></TH><TH class="tcm1" id="WDTCf8cb5357" nowrap style="white-space:nowrap;" valign="top" width="-1"><TABLE border="0" cellpadding="0" cellspacing="0" class="headerTable__5c8c1a2e" style="table-layout:fixed;font-size:100%;" width="100%"><TR class="tcm1"><TD nowrap style="overflow:hidden;text-overflow:ellipsis;vertical-align:middle;white-space:nowrap;" title="Replica" valign="top"><SPAN id="WDTCf8cb5357_handle">&nbsp;Replica&nbsp;</SPAN><INPUT name="client-reorder_5c8c1a2e" type="hidden" value="1"></TD><TD class="tcm1" onkeydown="if (event.keyCode == 13) { return tcDND(event, 1, 'WDTCf8cb5357', 'DD_5c8c1a2e'); }" onmousedown="return tcDND(event, 1, 'WDTCf8cb5357', 'DD_5c8c1a2e');" onmouseover="this.style.cursor = 'e-resize';" style="vertical-align:middle;" width="3px"><IMG align="center" alt="" border="0" height="" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/tbl13.gif" style="display:block;width:3px;" title="" width=""><INPUT name="client-resize_5c8c1a2e" type="hidden" value="-1"></TD></TR></TABLE></TH><TH class="tcm1" id="WDTC3b3806e1" nowrap style="white-space:nowrap;" valign="top" width="-1"><TABLE border="0" cellpadding="0" cellspacing="0" class="headerTable__5c8c1a2e" style="table-layout:fixed;font-size:100%;" width="100%"><TR class="tcm1"><TD nowrap style="overflow:hidden;text-overflow:ellipsis;vertical-align:middle;white-space:nowrap;" title="Subtree" valign="top"><SPAN id="WDTC3b3806e1_handle">&nbsp;Subtree&nbsp;</SPAN><INPUT name="client-reorder_5c8c1a2e" type="hidden" value="2"></TD><TD class="tcm1" onkeydown="if (event.keyCode == 13) { return tcDND(event, 1, 'WDTC3b3806e1', 'DD_5c8c1a2e'); }" onmousedown="return tcDND(event, 1, 'WDTC3b3806e1', 'DD_5c8c1a2e');" onmouseover="this.style.cursor = 'e-resize';" style="vertical-align:middle;" width="3px"><IMG align="center" alt="" border="0" height="" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/tbl13.gif" style="display:block;width:3px;" title="" width=""><INPUT name="client-resize_5c8c1a2e" type="hidden" value="-1"></TD></TR></TABLE></TH><TH class="tcm1" id="WDTC6e3f3496" nowrap style="white-space:nowrap;" valign="top" width="-1"><TABLE border="0" cellpadding="0" cellspacing="0" class="headerTable__5c8c1a2e" style="table-layout:fixed;font-size:100%;" width="100%"><TR class="tcm1"><TD nowrap style="overflow:hidden;text-overflow:ellipsis;vertical-align:middle;white-space:nowrap;" title="Last result:" valign="top"><SPAN id="WDTC6e3f3496_handle">&nbsp;Last result:&nbsp;</SPAN><INPUT name="client-reorder_5c8c1a2e" type="hidden" value="3"></TD><TD class="tcm1" onkeydown="if (event.keyCode == 13) { return tcDND(event, 1, 'WDTC6e3f3496', 'DD_5c8c1a2e'); }" onmousedown="return tcDND(event, 1, 'WDTC6e3f3496', 'DD_5c8c1a2e');" onmouseover="this.style.cursor = 'e-resize';" style="vertical-align:middle;" width="3px"><IMG align="center" alt="" border="0" height="" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/tbl13.gif" style="display:block;width:3px;" title="" width=""><INPUT name="client-resize_5c8c1a2e" type="hidden" value="-1"></TD></TR></TABLE></TH><TH class="tcm1" id="WDTCd376c54e" nowrap style="white-space:nowrap;" valign="top" width="-1"><TABLE border="0" cellpadding="0" cellspacing="0" class="headerTable__5c8c1a2e" style="table-layout:fixed;font-size:100%;" width="100%"><TR class="tcm1"><TD nowrap style="overflow:hidden;text-overflow:ellipsis;vertical-align:middle;white-space:nowrap;" title="State" valign="top"><SPAN id="WDTCd376c54e_handle">&nbsp;State&nbsp;</SPAN><INPUT name="client-reorder_5c8c1a2e" type="hidden" value="4"></TD><TD class="tcm1" onkeydown="if (event.keyCode == 13) { return tcDND(event, 1, 'WDTCd376c54e', 'DD_5c8c1a2e'); }" onmousedown="return tcDND(event, 1, 'WDTCd376c54e', 'DD_5c8c1a2e');" onmouseover="this.style.cursor = 'e-resize';" style="vertical-align:middle;" width="3px"><IMG align="center" alt="" border="0" height="" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/tbl13.gif" style="display:block;width:3px;" title="" width=""><INPUT name="client-resize_5c8c1a2e" type="hidden" value="-1"></TD></TR></TABLE></TH><TH class="tcm1" id="WDTCa3f9ff3b" nowrap style="white-space:nowrap;" valign="top" width="-1"><TABLE border="0" cellpadding="0" cellspacing="0" class="headerTable__5c8c1a2e" style="table-layout:fixed;font-size:100%;" width="100%"><TR class="tcm1"><TD nowrap style="overflow:hidden;text-overflow:ellipsis;vertical-align:middle;white-space:nowrap;" title="Queue size" valign="top"><SPAN id="WDTCa3f9ff3b_handle">&nbsp;Queue size&nbsp;</SPAN><INPUT name="client-reorder_5c8c1a2e" type="hidden" value="5"></TD><TD class="tcm1" onkeydown="if (event.keyCode == 13) { return tcDND(event, 1, 'WDTCa3f9ff3b', 'DD_5c8c1a2e'); }" onmousedown="return tcDND(event, 1, 'WDTCa3f9ff3b', 'DD_5c8c1a2e');" onmouseover="this.style.cursor = 'e-resize';" style="vertical-align:middle;" width="3px"><IMG align="center" alt="" border="0" height="" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/tbl13.gif" style="display:block;width:3px;" title="" width=""><INPUT name="client-resize_5c8c1a2e" type="hidden" value="-1"></TD></TR></TABLE></TH><TH class="tcm1" colspan="1" nowrap style="visibility:hidden" width="1px">&nbsp;</TH></TR></TBODY><INPUT class="te1" id="WTETLa48fac37" name="action_5c8c1a2e" title="" type="hidden" value=""></TABLE><DIV h1bid="H1B_5c8c1a2e" h2bid="H2B_5c8c1a2e" id="DD_5c8c1a2e"><TABLE border="1" cellpadding="0" cellspacing="0" class="tbl1" datatable="1" style="border-width:0px 1px 0px 1px;" width="100%"><TBODY id="H2B_5c8c1a2e" style="height:0.5px;overflow:scroll;"><TR><TH class="tcm5" id="WTCf65b9579_hidden" nowrap style="white-space:nowrap;" valign="top"><TABLE border="0" cellpadding="0" cellspacing="0" class="headerTable__5c8c1a2e" style="table-layout:auto;font-size:100%;" width="100%"><TR class="tcm1"><TD nowrap style="overflow:hidden;text-overflow:ellipsis;vertical-align:middle;white-space:nowrap;" title="Select" valign="top"></TD><TD class="tcm1" style="vertical-align:middle;" width="3px"><INPUT name="client-resize_5c8c1a2e" type="hidden" value="-1"></TD></TR></TABLE></TH><TH class="tcm5" id="WDTCf8cb5357_hidden" nowrap style="white-space:nowrap;" valign="top"><TABLE border="0" cellpadding="0" cellspacing="0" class="headerTable__5c8c1a2e" style="table-layout:fixed;font-size:100%;" width="100%"><TR class="tcm1"><TD nowrap style="overflow:hidden;text-overflow:ellipsis;vertical-align:middle;white-space:nowrap;" title="Replica" valign="top"></TD><TD class="tcm1" style="vertical-align:middle;" width="3px"><INPUT name="client-resize_5c8c1a2e" type="hidden" value="-1"></TD></TR></TABLE></TH><TH class="tcm5" id="WDTC3b3806e1_hidden" nowrap style="white-space:nowrap;" valign="top"><TABLE border="0" cellpadding="0" cellspacing="0" class="headerTable__5c8c1a2e" style="table-layout:fixed;font-size:100%;" width="100%"><TR class="tcm1"><TD nowrap style="overflow:hidden;text-overflow:ellipsis;vertical-align:middle;white-space:nowrap;" title="Subtree" valign="top"></TD><TD class="tcm1" style="vertical-align:middle;" width="3px"><INPUT name="client-resize_5c8c1a2e" type="hidden" value="-1"></TD></TR></TABLE></TH><TH class="tcm5" id="WDTC6e3f3496_hidden" nowrap style="white-space:nowrap;" valign="top"><TABLE border="0" cellpadding="0" cellspacing="0" class="headerTable__5c8c1a2e" style="table-layout:fixed;font-size:100%;" width="100%"><TR class="tcm1"><TD nowrap style="overflow:hidden;text-overflow:ellipsis;vertical-align:middle;white-space:nowrap;" title="Last result:" valign="top"></TD><TD class="tcm1" style="vertical-align:middle;" width="3px"><INPUT name="client-resize_5c8c1a2e" type="hidden" value="-1"></TD></TR></TABLE></TH><TH class="tcm5" id="WDTCd376c54e_hidden" nowrap style="white-space:nowrap;" valign="top"><TABLE border="0" cellpadding="0" cellspacing="0" class="headerTable__5c8c1a2e" style="table-layout:fixed;font-size:100%;" width="100%"><TR class="tcm1"><TD nowrap style="overflow:hidden;text-overflow:ellipsis;vertical-align:middle;white-space:nowrap;" title="State" valign="top"></TD><TD class="tcm1" style="vertical-align:middle;" width="3px"><INPUT name="client-resize_5c8c1a2e" type="hidden" value="-1"></TD></TR></TABLE></TH><TH class="tcm5" id="WDTCa3f9ff3b_hidden" nowrap style="white-space:nowrap;" valign="top"><TABLE border="0" cellpadding="0" cellspacing="0" class="headerTable__5c8c1a2e" style="table-layout:fixed;font-size:100%;" width="100%"><TR class="tcm1"><TD nowrap style="overflow:hidden;text-overflow:ellipsis;vertical-align:middle;white-space:nowrap;" title="Queue size" valign="top"></TD><TD class="tcm1" style="vertical-align:middle;" width="3px"><INPUT name="client-resize_5c8c1a2e" type="hidden" value="-1"></TD></TR></TABLE></TH><TH class="tcm5" colspan="1" nowrap style="visibility:hidden" width="1px"></TH></TR></TBODY><TBODY abid="AB_5c8c1a2e" doh="21" dr="3" id="DB_5c8c1a2e" mpc="10" mrd="1" pcc="5" rpp="12" rpv="12" spid="DD_5c8c1a2e"><TR id="TR_0_5c8c1a2e" row="0"><TD class="tbls2" headers="WTCf65b9579" id="WTCf65b9579_0" nowrap style="position:relative;" valign="TOP"><IMG alt="Select" border="0" height="0" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/o.gif" title="Select" width="0"><DIV style="color:#000000;text-align:center;"><LABEL for="client-select_5c8c1a2e_0"><IMG align="top" alt="Row1 Select" border="0" height="1px" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/o.gif" title="Row1 Select" width="1px"></LABEL><INPUT checked id="client-select_5c8c1a2e_0" name="client-select_5c8c1a2e" onblur="" onclick="return doRTgl(this);" onfocus="" type="Radio" value="0"></DIV></TD><TD class="tbls2" headers="WDTCf8cb5357" id="WDTCf8cb5357_0" nowrap style="position:relative;" title="Replica" valign="TOP"><IMG alt="Replica" border="0" height="0" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/o.gif" title="Replica" width="0"><DIV class="cel1"><TABLE border="0" cellpadding="0" cellspacing="0" dir="LTR" style="font-size:100%;" width="100%"><TR><TD style="font-family:Arial, Helvetica, sans-serif;float:left;font-size:100%;"><TABLE border="0" cellpadding="0" cellspacing="0" class="lyt1" dir="LTR"><TR><TD align="left" class="lyt2" valign="top"><SPAN class="txt" id="value_1043096305" style=";font-size:100%;" tabindex="0">master1-dc</SPAN></TD></TR></TABLE></TD></TR></TABLE></DIV></TD><TD class="tbls2" headers="WDTC3b3806e1" id="WDTC3b3806e1_0" nowrap style="position:relative;" title="Subtree" valign="TOP"><IMG alt="Subtree" border="0" height="0" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/o.gif" title="Subtree" width="0"><DIV class="cel1"><TABLE border="0" cellpadding="0" cellspacing="0" dir="LTR" style="font-size:100%;" width="100%"><TR><TD style="font-family:Arial, Helvetica, sans-serif;float:left;font-size:100%;"><TABLE border="0" cellpadding="0" cellspacing="0" class="lyt1" dir="LTR"><TR><TD align="left" class="lyt2" valign="top"><SPAN class="txt" id="value_1902509312" style=";font-size:100%;" tabindex="0">o=myorg</SPAN></TD></TR></TABLE></TD></TR></TABLE></DIV></TD><TD class="tbls2" headers="WDTC6e3f3496" id="WDTC6e3f3496_0" nowrap style="position:relative;" title="Last result:" valign="TOP"><IMG alt="Last result:" border="0" height="0" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/o.gif" title="Last result:" width="0"><DIV class="cel1"><TABLE border="0" cellpadding="0" cellspacing="0" dir="LTR" style="font-size:100%;" width="100%"><TR><TD style="font-family:Arial, Helvetica, sans-serif;float:left;font-size:100%;"><TABLE border="0" cellpadding="0" cellspacing="0" class="lyt1" dir="LTR"><TR><TD align="left" class="lyt2" valign="top"><SPAN class="txt" id="value_74877780" style=";font-size:100%;" tabindex="0">OK</SPAN></TD></TR></TABLE></TD></TR></TABLE></DIV></TD><TD class="tbls2" headers="WDTCd376c54e" id="WDTCd376c54e_0" nowrap style="position:relative;" title="State" valign="TOP"><IMG alt="State" border="0" height="0" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/o.gif" title="State" width="0"><DIV class="cel1"><TABLE border="0" cellpadding="0" cellspacing="0" dir="LTR" style="font-size:100%;" width="100%"><TR><TD style="font-family:Arial, Helvetica, sans-serif;float:left;font-size:100%;"><TABLE border="0" cellpadding="0" cellspacing="0" class="lyt1" dir="LTR"><TR><TD align="left" class="lyt2" valign="top"><SPAN class="txt" id="value_1716011392" style=";font-size:100%;" tabindex="0">Ready</SPAN></TD></TR></TABLE></TD></TR></TABLE></DIV></TD><TD class="tbls2" headers="WDTCa3f9ff3b" id="WDTCa3f9ff3b_0" nowrap style="position:relative;" title="Queue size" valign="TOP"><IMG alt="Queue size" border="0" height="0" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/o.gif" title="Queue size" width="0"><DIV class="cel1"><TABLE border="0" cellpadding="0" cellspacing="0" dir="LTR" style="font-size:100%;" width="100%"><TR><TD style="font-family:Arial, Helvetica, sans-serif;float:left;font-size:100%;"><TABLE border="0" cellpadding="0" cellspacing="0" class="lyt1" dir="LTR"><TR><TD align="left" class="lyt2" valign="top"><SPAN class="txt" id="value_267306888" style=";font-size:100%;" tabindex="0">555555555</SPAN></TD></TR></TABLE></TD></TR></TABLE></DIV></TD></TR><TR id="TR_1_5c8c1a2e" row="1"><TD class="tbl4" headers="WTCf65b9579" id="WTCf65b9579_1" nowrap style="position:relative;" valign="TOP"><IMG alt="Select" border="0" height="0" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/o.gif" title="Select" width="0"><DIV style="color:#000000;text-align:center;"><LABEL for="client-select_5c8c1a2e_1"><IMG align="top" alt="Row2 Select" border="0" height="1px" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/o.gif" title="Row2 Select" width="1px%"></LABEL><INPUT id="client-select_5c8c1a2e_1" name="client-select_5c8c1a2e" onblur="" onclick="return doRTgl(this);" onfocus="" type="Radio" value="1"></DIV></TD><TD class="tbl4" headers="WDTCf8cb5357" id="WDTCf8cb5357_1" nowrap style="position:relative;" title="Replica" valign="TOP"><IMG alt="Replica" border="0" height="0" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/o.gif" title="Replica" width="0"><DIV class="cel1"><TABLE border="0" cellpadding="0" cellspacing="0" dir="LTR" style="font-size:100%;" width="100%"><TR><TD style="font-family:Arial, Helvetica, sans-serif;float:left;font-size:100%;"><TABLE border="0" cellpadding="0" cellspacing="0" class="lyt1" dir="LTR"><TR><TD align="left" class="lyt2" valign="top" width="100%"><SPAN class="txt" id="value_901294560" style=";font-size:100%;" tabindex="0">master2-dc</SPAN></TD></TR></TABLE></TD></TR></TABLE></DIV></TD><TD class="tbl4" headers="WDTC3b3806e1" id="WDTC3b3806e1_1" nowrap style="position:relative;" title="Subtree" valign="TOP"><IMG alt="Subtree" border="0" height="0" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/o.gif" title="Subtree" width="0"><DIV class="cel1"><TABLE border="0" cellpadding="0" cellspacing="0" dir="LTR" style="font-size:100%;" width="100%"><TR><TD style="font-family:Arial, Helvetica, sans-serif;float:left;font-size:100%;"><TABLE border="0" cellpadding="0" cellspacing="0" class="lyt1" dir="LTR"><TR><TD align="left" class="lyt2" valign="top"><SPAN class="txt" id="value_589567448" style=";font-size:100%;" tabindex="0">o=mybank</SPAN></TD></TR></TABLE></TD></TR></TABLE></DIV></TD><TD class="tbl4" headers="WDTC6e3f3496" id="WDTC6e3f3496_1" nowrap style="position:relative;" title="Last result:" valign="TOP"><IMG alt="Last result:" border="0" height="0" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/o.gif" title="Last result:" width="0"><DIV class="cel1"><TABLE border="0" cellpadding="0" cellspacing="0" dir="LTR" style="font-size:100%;" width="100%"><TR><TD style="font-family:Arial, Helvetica, sans-serif;float:left;font-size:100%;"><TABLE border="0" cellpadding="0" cellspacing="0" class="lyt1" dir="LTR"><TR><TD align="left" class="lyt2" valign="top"><SPAN class="txt" id="value_1995752575" style=";font-size:100%;" tabindex="0">OK</SPAN></TD></TR></TABLE></TD></TR></TABLE></DIV></TD><TD class="tbl4" headers="WDTCd376c54e" id="WDTCd376c54e_1" nowrap style="position:relative;" title="State" valign="TOP"><IMG alt="State" border="0" height="0" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/o.gif" title="State" width="0"><DIV class="cel1"><TABLE border="0" cellpadding="0" cellspacing="0" dir="LTR" style="font-size:100%;" width="100%"><TR><TD style="font-family:Arial, Helvetica, sans-serif;float:left;font-size:100%;"><TABLE border="0" cellpadding="0" cellspacing="0" class="lyt1" dir="LTR"><TR><TD align="left" class="lyt2" valign="top"><SPAN class="txt" id="value_541365533" style=";font-size:100%;" tabindex="0">Ready</SPAN></TD></TR></TABLE></TD></TR></TABLE></DIV></TD><TD class="tbl4" headers="WDTCa3f9ff3b" id="WDTCa3f9ff3b_1" nowrap style="position:relative;" title="Queue size" valign="TOP"><IMG alt="Queue size" border="0" height="0" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/o.gif" title="Queue size" width="0"><DIV class="cel1"><TABLE border="0" cellpadding="0" cellspacing="0" dir="LTR" style="font-size:100%;" width="100%"><TR><TD style="font-family:Arial, Helvetica, sans-serif;float:left;font-size:100%;"><TABLE border="0" cellpadding="0" cellspacing="0" class="lyt1" dir="LTR"><TR><TD align="left" class="lyt2" valign="top"><SPAN class="txt" id="value_93022098" style=";font-size:100%;" tabindex="0">444444444444</SPAN></TD></TR></TABLE></TD></TR></TABLE></DIV></TD></TR><TR id="TR_2_5c8c1a2e" row="2"><TD class="tbl2" headers="WTCf65b9579" id="WTCf65b9579_2" nowrap style="position:relative;" valign="TOP"><IMG alt="Select" border="0" height="0" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/o.gif" title="Select" width="0"><DIV style="color:#000000;text-align:center;"><LABEL for="client-select_5c8c1a2e_2"><IMG align="top" alt="Row3 Select" border="0" height="1px" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/o.gif" title="Row3 Select" width="1px"></LABEL><INPUT id="client-select_5c8c1a2e_2" name="client-select_5c8c1a2e" onblur="" onclick="return doRTgl(this);" onfocus="" type="Radio" value="2"></DIV></TD><TD class="tbl2" headers="WDTCf8cb5357" id="WDTCf8cb5357_2" nowrap style="position:relative;" title="Replica" valign="TOP"><IMG alt="Replica" border="0" height="0" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/o.gif" title="Replica" width="0"><DIV class="cel1"><TABLE border="0" cellpadding="0" cellspacing="0" dir="LTR" style="font-size:100%;" width="100%"><TR><TD style="font-family:Arial, Helvetica, sans-serif;float:left;font-size:100%;"><TABLE border="0" cellpadding="0" cellspacing="0" class="lyt1" dir="LTR"><TR><TD align="left" class="lyt2" valign="top"><SPAN class="txt" id="value_851238299" style=";font-size:100%;" tabindex="0">master2-dr</SPAN></TD></TR></TABLE></TD></TR></TABLE></DIV></TD><TD class="tbl2" headers="WDTC3b3806e1" id="WDTC3b3806e1_2" nowrap style="position:relative;" title="Subtree" valign="TOP"><IMG alt="Subtree" border="0" height="0" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/o.gif" title="Subtree" width="0"><DIV class="cel1"><TABLE border="0" cellpadding="0" cellspacing="0" dir="LTR" style="font-size:100%;" width="100%"><TR><TD style="font-family:Arial, Helvetica, sans-serif;float:left;font-size:100%;"><TABLE border="0" cellpadding="0" cellspacing="0" class="lyt1" dir="LTR"><TR><TD align="left" class="lyt2" valign="top"><SPAN class="txt" id="value_2033711160" style=";font-size:100%;" tabindex="0">o=myorg</SPAN></TD></TR></TABLE></TD></TR></TABLE></DIV></TD><TD class="tbl2" headers="WDTC6e3f3496" id="WDTC6e3f3496_2" nowrap style="position:relative;" title="Last result:" valign="TOP"><IMG alt="Last result:" border="0" height="0" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/o.gif" title="Last result:" width="0"><DIV class="cel1"><TABLE border="0" cellpadding="0" cellspacing="0" dir="LTR" style="font-size:100%;" width="100%"><TR><TD style="font-family:Arial, Helvetica, sans-serif;float:left;font-size:100%;"><TABLE border="0" cellpadding="0" cellspacing="0" class="lyt1" dir="LTR"><TR><TD align="left" class="lyt2" valign="top"><SPAN class="txt" id="value_1793904981" style=";font-size:100%;" tabindex="0">OK</SPAN></TD></TR></TABLE></TD></TR></TABLE></DIV></TD><TD class="tbl2" headers="WDTCd376c54e" id="WDTCd376c54e_2" nowrap style="position:relative;" title="State" valign="TOP"><IMG alt="State" border="0" height="0" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/o.gif" title="State" width="0"><DIV class="cel1"><TABLE border="0" cellpadding="0" cellspacing="0" dir="LTR" style="font-size:100%;" width="100%"><TR><TD style="font-family:Arial, Helvetica, sans-serif;float:left;font-size:100%;"><TABLE border="0" cellpadding="0" cellspacing="0" class="lyt1" dir="LTR"><TR><TD align="left" class="lyt2" valign="top"><SPAN class="txt" id="value_921368573" style=";font-size:100%;" tabindex="0">Ready</SPAN></TD></TR></TABLE></TD></TR></TABLE></DIV></TD><TD class="tbl2" headers="WDTCa3f9ff3b" id="WDTCa3f9ff3b_2" nowrap style="position:relative;" title="Queue size" valign="TOP"><IMG alt="Queue size" border="0" height="0" src="http://10.9.45.89:1200/IDSWebApp/resources/wcl/images/o.gif" title="Queue size" width="0"><DIV class="cel1"><TABLE border="0" cellpadding="0" cellspacing="0" dir="LTR" style="font-size:100%;" width="100%"><TR><TD style="font-family:Arial, Helvetica, sans-serif;float:left;font-size:100%;"><TABLE border="0" cellpadding="0" cellspacing="0" class="lyt1" dir="LTR"><TR><TD align="left" class="lyt2" valign="top"><SPAN class="txt" id="value_1563880605" style=";font-size:100%;" tabindex="0">333333333</SPAN></TD></TR></TABLE></TD></TR></TABLE></DIV></TD></TR></TBODY></TABLE></DIV></DIV></SPAN></FORM></BODY></HTML>

你能推荐一下吗?

最佳答案

要获取行,请使用 tr[row] css 选择器。要获取副本,请使用td[title="Replica"]并获取队列大小td[title="Queue size"] CSS 选择器。

new WebDriverWait(driver, 10)
        .until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector("tr[row]")))
        .forEach(row -> {
            String replica = row.findElement(By.cssSelector("td[title='Replica']")).getText().trim();
            String queueSize = row.findElement(By.cssSelector("td[title='Queue size']")).getText().trim();
            System.out.println(String.format("%s %s", replica, queueSize));
        });

关于java - 使用 Selenium JAVA 代码读取具有 <SPAN> 标签的列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59488139/

相关文章:

java - Jackson JSON 处理器问题

java - 如何定义通用排序类

java - 在 AsyncTask 中向 OSMDroid-Map 添加叠加项

java - 使用 Selenium Webdriver 提取包含 <br> 标记的文本

python - Selenium:如何在 AWS 上使用 Headless Chrome?

javascript - 将表格单元格添加到现有表格行,jQuery

HTML 表格交错单元格合并

java - 自动连接到 hibernate 拦截器

python - 如何使用selenium选择单选按钮

html - 在网格中定位照片 (HTML)