Reputation: 58
I am trying to get text of an element which contains another element in it and a text. But it return something from the inherited element and the text. Is there a way I can get only the text?
Upvotes: 0
Views: 129
Reputation: 50809
The text is in the <h5>
tag, you need to locate that element
String text = driver.findElement(By.xpath("//img[@class='img-circle owner-image']/..")).getText();
Upvotes: 2
Reputation: 1270
Other way of locating element
String text = driver.findElement(By.xpath("//img[contains(@class,'img-circle')]")).getText();
Upvotes: 0