I'm using selenium webdriver to get some text on my webpage using xpath.
This is the code
<a class="ng-binding" data-toggle="tab" href="#tabCreatedByMe">
Created By Me
<span class="badge ng-binding">3</span>
</a>
I need to get the number '3'. this number is changing everytime
I made this code but it does not return anything
public String getAmountSubtab1() throws InterruptedException{
WebElement s = driver.findElement(By.xpath("//*[@class='badge ng-binding']"));
return s.getText(); }
Suggestions?
s.getTextreturns nothing? If you change it to a.findElements, and check the size of the collection that is returned, how many elements does it have? What if you make your XPath more targetted?//span[@class='badge ng-binding']