HTML
<div id="nav" data-offset-top="100">
<div class="row top-space bor-box" ng-show="BindList.length > 0">
<span class="pull-left text-info dropdown">
<a id="Action" class="btn btn-link text-info" href="javascript:void(0);" data-toggle="dropdown">
Action
<span class="caret"/>
</a>
|
<span>
|
<span>
|
<span style="top: 2px; position: relative;">
Total Count:
<b class="ng-binding">23904</b>
</span>
</span>
</div>
问题
提取23904
值
我的xpath
driver.findElement(By.xpath("//*[@id='nav']/div[1]/span[1]/span[3]/b")).getText();
输出将是空字符串,可以在上面的xpath中任意一点问题,或者请指导我
答案 0 :(得分:0)
尝试以下XPath: -
//div[@id='nav']//b[@class='ng-binding']/text()
它会返回
23904
希望它会对你有所帮助:)。
答案 1 :(得分:0)
使用此代码:
driver.findElement(By.xpath("//b[@class='ng-binding']")).getText();
答案 2 :(得分:0)
尝试下面的xpath amd让我们看看它是否适合你 -
//*[@id="nav"]/div/span/span/span/span/b
答案 3 :(得分:0)
试试这个:
driver.findElement(By.xpath("//b[@class='ng-binding']")).getAttribute("innerText")