Using the text function, we can find the elements using the text present in them.
<button type="button">Blueberry</button> (Blueberry is text here)
xpath with text : //button[text()='Blueberry']
But when the text is dynamic we have to use contains function along with text function. For this to work some part of the string must be static.
<button type="button">*****berry</button>
xpath with text : //button[contains(text(),'berry')]