You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the withText() method identifies only case sensitive text. That works for many cases but can also be a source of instability. By definition, withText() searches for elements that contain a specific sub-string. If said sub-string moves within the same sentence, then it's very likely for it to change all lowercase to the first character being a capital letter - which will break the tests.
In my humble opinion, a preferred solution would be the addition of a separate method, like Test Library'sgetByText(). Here's a link to an example of getByText():
// Matching a string:
getByText('Hello World') // full string match
getByText('llo Worl', { exact: false }) // substring match
getByText('hello world', { exact: false }) // ignore case
// Matching a regex:
getByText(/World/) // substring match
getByText(/world/i) // substring match, ignore case
getByText(/^hello world$/i) // full string match, ignore case
getByText(/Hello W?oRlD/i) // advanced regex
// Matching with a custom function:
getByText((content, element) => content.startsWith('Hello'))
What do you get instead?
The withText() method identifies only case sensitive text.
Details
CodeceptJS version: v3.0.2
NodeJS Version: v14.8.0
Operating System: MacOS 10.15.4
playwright
The text was updated successfully, but these errors were encountered:
What are you trying to achieve?
Currently, the
withText()
method identifies only case sensitive text. That works for many cases but can also be a source of instability. By definition,withText()
searches for elements that contain a specific sub-string. If said sub-string moves within the same sentence, then it's very likely for it to change all lowercase to the first character being a capital letter - which will break the tests.In my humble opinion, a preferred solution would be the addition of a separate method, like Test Library's
getByText()
. Here's a link to an example ofgetByText()
:What do you get instead?
The
withText()
method identifies only case sensitive text.Details
The text was updated successfully, but these errors were encountered: