How to find partial text and count text

Hi, I want to count text only “0008” on webpage, but as partial text. I try use

WebDriver driver = DriverFactory.getWebDriver()

int countSize = driver.findElements(By.xpath('//*[text() = "0008"]')).size()


It not found text, because text value in elements is ex. 5468 48** **** 0008

Screenshot at Feb 18 20-19-01

Would you recommend what I could do, Thank you very much.

Your xpath should be:

//*[contains(text(), '0008')]

However, I would recommend identifying the element that contains the text more exactly (instead of the ‘//*’ call). If you can share the html for one of these text nodes, I could offer a specific solution.

1 Like

I try follow


However, I can’t share the html, but you can could offer a specific solution by example from
how to count text all ‘Statements’ on page?. that is 26 text

Thanks for the reply

No, you haven’t. Please check the syntax carefully.

No, I can’t. The HTML for the katalon studio homepage is going to be completely different from your application.

Thank you for answer

this is correct

Before, I don’t check carefully.

1 Like