While testing web applications, you will also encounter situations where developers don't assign any attributes to the elements and it becomes difficult to locate elements.
Using the CSS selectors or XPath, we can locate elements based on their text contents. In this recipe, we will explore methods to locate elements using text values.
For locating elements by using their text contents, CSS selectors and XPath provide methods to find text within the elements. If an element contains specific text, this will return the element back to the test.
Using CSS selector Contains Pseudo-Class
CSS selectors provide the
contains() pseudo-class which can be used to see if an element contains the specified text. For ...