Skip to content

[Feature Request] withText() case-insensitive option #2704

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
stordopoulos opened this issue Nov 30, 2020 · 1 comment
Closed

[Feature Request] withText() case-insensitive option #2704

stordopoulos opened this issue Nov 30, 2020 · 1 comment

Comments

@stordopoulos
Copy link

stordopoulos commented Nov 30, 2020

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 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
@kobenguyent
Copy link
Collaborator

I think this is resolved by #4100

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants