user3422485
user3422485

Reputation: 47

Selenium find text of span

<td style="border-bottom: transparent;padding-bottom:0px;" colspan="14">
 <ul class="pager">
  <span> Total number of rows: 3926 (page 1 of 79)</span>
</ul>
</td>

I found the element from pager class,

  List<WebElement> webElement = getDriver().findElements(By.xpath("//ul[@class='pager']"));
          List<WebElement> childElements = webElement.get(0).findElements(By.xpath("./child::*"));
          sout("childElement text " + childElements.get(0).getAttribute("innerHTML")); // returns empty String
          sout("childElement text " + childElements.get(0).getTagName()); // returns "span"

also tried this, in chrome it marks with yellow color what I need, but selenium driver cant find it

 //*[contains(text(),' Total number of rows')]

Upvotes: 0

Views: 46

Answers (1)

Md. Fazlul Hoque
Md. Fazlul Hoque

Reputation: 16187

span tag is the child node of ul tag. So you can try it as follows:

//ul[@class='pager']/span

See the result from here

Upvotes: 1

Related Questions