0

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?

enter image description here

1
  • Which text are you trying to get? Commented Aug 21, 2018 at 13:28

2 Answers 2

2

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();
Sign up to request clarification or add additional context in comments.

Comments

0

Other way of locating element

String text = driver.findElement(By.xpath("//img[contains(@class,'img-circle')]")).getText();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.