Skip to content
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

Trim selector text by default? #25

Open
cowboyd opened this issue Aug 30, 2021 · 3 comments
Open

Trim selector text by default? #25

cowboyd opened this issue Aug 30, 2021 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@cowboyd
Copy link
Member

cowboyd commented Aug 30, 2021

Safari includes up to one newline in its innerText property for elements. Why, I'm not sure, but it ends up that you don't match your selectors on different platforms:

image showing search for selector DEFAULT, but no match because the actual selector is DEFAULT + newline

Should we trim the selector before matching against it?

@cowboyd cowboyd added the question Further information is requested label Aug 30, 2021
cherewaty pushed a commit that referenced this issue Sep 2, 2021
@cowboyd
Copy link
Member Author

cowboyd commented Sep 21, 2021

One posible strategy would be instead of trimming the element locator, to always wrap the locator in a matcher. The default would be trimmed, but we could also have a strictEquals locator that that did a === as its match. So that if it was what you really wanted you could match that.

@jnicklas
Copy link
Collaborator

Ugh, this is annoying. IIRC Capybara does trim the text, which seems reasonable since whitespace is very rarely relevant in HTML documents anyway. I think the HTML interactor could do this, that way it'd still be overridable if someone really wants to.

@jnicklas jnicklas added this to the v1 milestone Oct 26, 2021
@wKich
Copy link
Member

wKich commented Oct 26, 2021

Most interactors override the locator method. So I think we should implement trimming on the internal level, like adding the special trim matcher.

@cowboyd cowboyd removed this from the v1 milestone Nov 3, 2021
@cherewaty cherewaty removed their assignment Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants