从下面的html页面我试着写下面的关键字,但我很难获得使用通用xpath的确切键数。
html是:
<table class="tabletext">
<tbody>
<tr>
<td style="font-weight:bold; font-size:large">Collector Information</td>
</tr>
</tbody>
</table>
<table class="tabletext">
<tbody>
<tr>
<td style="font-size:medium" colspan="2" align="left">
<table>
<tbody>
<tr>
<td></td>
</tr>
<tr>
<td style="color:Navy; font-size:20px; border-bottom: solid 1px black; " width="700px">General Application Statistics</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td style="font-weight:bold; font-size:medium">Local Radios</td>
<td align="left">AA.5E.AZ.21.13.04[Z0136FBZ]</td>
</tr>
<tr>
<td style="font-weight:bold; font-size:medium">MAC Address</td>
<td align="left">91-99-99-0C-66-B2</td>
</tr>
<tr>
<td style="font-weight:bold; font-size:medium">Version</td>
<td align="left">14.48.24.0</td>
</tr>
<tr>
<td style="font-size:medium" colspan="2" align="left">
<table>
<tbody>
<tr>
<td></td>
</tr>
<tr>
<td style="color:Navy; font-size:20px; border-bottom: solid 1px black; " width="700px">Legacy Configuration</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td style="font-weight:bold; font-size:medium">Default Geo Code</td>
<td align="left">AF.ZA.QE.23.23.1F</td>
</tr>
</tbody>
</table>
这些是我的关键字..我能够在&#34;获取收集器信息部分&#34;关键词。但是我没有找到正确的xpath来获取&#34;从收集者信息部分获取值&#34;
Obtain Collector Information Sections
[Documentation]
${No_Of_Sections} = get matching xpath count //table[2]/tbody/tr[td/table/tbody/tr[2]/td[@style='color:Navy; font-size:20px; border-bottom: solid 1px black; ']]
@{list} = Create List
: FOR ${Count} IN Range 1 ${No_Of_Sections}
\ ${Section_Header_Name} = Get Value //table[2]/tbody/tr[td/table/tbody/tr[2]/td[@style='color:Navy; font-size:20px; border-bottom: solid 1px black; ']][${Count}]
\ ${Information_Section_${Count}} = Obtain Values From Collector Information Sections ${Section_Header_Name}
\ log dictionary ${Information_Section_${Count}}
\ Append To List ${list} ${Information_Section_${Count}}
Obtain Values From Collector Information Sections
[Documentation]
[Arguments] ${Section_Header_Name}
${Information_Section} = Create Dictionary
${No_Of_Key_Value} = get matching xpath count //table[2]/tbody/tr[td/table/tbody/tr[2]/td[normalize-space(text())='${Section_Header_Name}']]/following-sibling::tr[1]/td
: FOR ${Count} IN Range 1 ${No_Of_Key_Value}
\ ${Key} = Get Value //table[2]/tbody/tr[td/table/tbody/tr[2]/td[normalize-space(text())='${Section_Header_Name}']]/following-sibling::tr[${Count}]/td[1]
\ ${Value} = Get Value //table[2]/tbody/tr[td/table/tbody/tr[2]/td[normalize-space(text())='${Section_Header_Name}']]/following-sibling::tr[${Count}]/td[2]
\ set to dictionary ${Information_Section} ${Key} ${Value}
[Return] ${Information_Section}
我未能在此线上得到准确的计数。我打算只获取键列表(不是任何值)将其添加到Dictionary。
${No_Of_Key_Value} = get matching xpath count //table[2]/tbody/tr[td/table/tbody/tr[2]/td[normalize-space(text())='${Section_Header_Name}']]/following-sibling::tr[1]/td
上面一个是返回键&amp;价值对集。但我只需要计算来自&#34;一般应用统计&#34;迭代循环的部分。
你能帮帮我吗!提前谢谢..