我很难访问文本为当前基金价值的对象。
在Chrome上使用Firebug,元素的xpath是:
//*[@id="poc"]/div[1]/div[4]/table/tbody/tr[1]/th/a
在Firefox上使用Firebug,元素的xpath是:
/html/body/div[2]/div[9]/div/div/div/div/div[2]/div[1]/div[4]/table/tbody/tr[1]/th/a
我很努力,但(我想还不够努力(使用下面的代码来访问动态更改"div[1]/div[4]"部分的对象。任何帮助都将不胜感激:
@FindBy(how = How.XPATH, using = "//a[starts-with(@id, 'poc')] and
contains[(@text, 'Current Fund Value')]")
或
@FindBy(how = How.XPATH, using = "//input[starts-with(@id, 'poc')] and
contains[(@linktext, 'Current Fund Value')]")
或
@FindBy(how = How.XPATH, using = "//input[contains[(@text, 'Current
Fund Value')]")
这是HTML
<table>
<tbody>
<tr>
<th>
<a class="tooltip abbr">
Current Fund Value:
</a>
</th>
<td class="value dollar"><span class="symbol">$</span><span class="amount"> 32,498</span><span class="decimal"><span class="point">.</span><span class="amount">90</span></span></td>
</tr>
</tbody>
</table>
更新:
具有相同文本的多个项目显示在不同的表中的方式如下:
第一张表
//*[@id="poc"]/div[1]/div[3]/table[1]/tbody/tr[1]/th/a
第二张表
//*[@id="poc"]/div[1]/div[3]/table[2]/tbody/tr[1]/th/a
3nd表格
//*[@id="poc"]/div[1]/div[3]/table[3]/tbody/tr[1]/th/a
我会选择基于文本的搜索
//table//a[contains(text(),'Current Fund Value:')]
因此,您有一个id为poc的元素,其中有多个表,其中一个表中有一个文本为"当前基金价值"的元素,如果这是正确的,那么在您点击poc元素后,您必须提到包含此文本的表。