How do you assert text in selenium?

How do you assert text in selenium?

To check for the presence of a specific text/value, we can use the getText() function to retrieve the content of an element from the HTML source code and compare it to the expected string.