1)我想捕获引用ID。但是,它将捕获控制台上的评论。
2)我正在使用selenium web驱动程序和java。
3)只想在控制台上打印报价ID所有细节都在下面提到。
我想使用selenium web driver从网页中捕获引用ID。这是我的dom结构和我使用过的代码。但相反,它是打印审阅文本是XPath的一部分。
我页面的Dom结构:
<tbody>
<tr>
<tr id="pricerow" valign="top">
<td nowrap="nowrap">
3661017
<br/>
<a class="selectMenuHome" style="color: gray; text-transform: none; text-decoration: underline;cursor:hand;" alt="TestSITA" title="TestSITA">Review</a>
</td>
<td nowrap="nowrap">UNITED KINGDOM</td>
<td>London</td>
<td> 1 Ropemaker Street, London, United Kingdom </td>
<td nowrap="nowrap">3456789</td>
<td nowrap="nowrap"/>
<td nowrap="nowrap">2 Mbps</td>
<td nowrap="nowrap">ME</td>
<td nowrap="nowrap">Business VPN Corporate</td>
<td nowrap="nowrap">211</td>
使用的Xpath:(.//*[@id='pricerow']/td[1])[1]
引用捕获代码:
public static void QuoteCapture() throws Exception{
logmessage = ExcelUtils.getCellData(Constant.testcaserownum,
Constant.TestStepID)
+ "; "
+ ExcelUtils.getCellData(Constant.testcaserownum,
Constant.TeststepDescription)
+ "; Action: Capture and stored value";
Log.info(logmessage);
String[] fetchfrompage = null;
ActionElement = FindElement();
if (ExcelUtils.getCellData(Constant.testcaserownum, Constant.Data1)
.isEmpty()) {
fetchfrompage = ActionElement.getText().split("\n");
ValueCaptured.add(fetchfrompage[0]);
// ValueCaptureindex=ValueCaptureindex+1;
int size = ValueCaptured.size();
size = size - 1;
logmessage = ValueCaptured.get(size)
+ "; Value has been stored in index: " + size;
}
Log.info(logmessage);
}