I write the autotest, which checks a certain field on the site, for compliance. Everything works fine, but: I usually refer to an element through randomelement.getText(); pick up the text.
There was a problem that in my case, the text I need (not in the tag) is in a div , and besides this text, there are other lines enclosed in tags (all this is in the aforementioned div ).
As a result, does not get "1 pc." , and for example: "Your book: 1 pc. Book title."
Question: can I somehow try to fish only "1 pc."?
I check the text with - assertEquals(radndomElement.getText(), "1 шт.");
I use: Java , Selenium , TestNg .