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

Testing "getText" driver method #98

Closed
aik099 opened this issue Dec 1, 2024 · 5 comments
Closed

Testing "getText" driver method #98

aik099 opened this issue Dec 1, 2024 · 5 comments

Comments

@aik099
Copy link
Member

aik099 commented Dec 1, 2024

Recently we've changed getText method in Selenium-based drivers to allow getting the text of the invisible elements or elements that are visible, but Selenium thinks they're not:

By doing so we've introduced a bug, that Selenium code was solving for us before:

  • trimming of the final text;
  • replacing the symbol with A0 ASCII code with a regular space.

While attempting to write a test about that I've found, that https://github.com/minkphp/MinkBrowserKitDriver implementation of getText don't support symbol with A0 ASCII code at all.

I've written all the necessary code for :

Should I submit these PRs?

// cc: @stof , @uuf6429 , @mvorisek

P.S.
As a bonus side effect the innerText does replace <br> with a regular space, which can result in spaces before/after the text, which we should also trim.

@mvorisek
Copy link
Contributor

mvorisek commented Dec 1, 2024

❤ and thank you for all your work!

@aik099
Copy link
Member Author

aik099 commented Dec 2, 2024

Example:

The text version of div.test element below is some text (the non-breakable space present, but maybe GitHub can't display it as-is), while it should be some text (no leading/trailing space and no non-breakable space):

<div class="test"><img src="..."><br/>some&nbsp;text<br/></div>

@uuf6429
Copy link
Member

uuf6429 commented Dec 2, 2024

Thanks for the investigation!

To a certain point, it may be even better to implement this on our side, since it gives us more control of what we want to provide to our users.
On that point, I would actually like to ask - what is the expected behaviour (esp. what our users expect)?

I'm asking because in some specific situations, the selenium behaviour might not be desired - say for example we do getText() on a <pre> or some element with css white-space: pre*; the spacing will be gone. Selenium seems to handle that specially though: https://github.com/SeleniumHQ/selenium/blob/a6b161a159c3d581b130f03a2e6e35f577f38dec/javascript/atoms/dom.js#L1171

On the other hand, this is definitely a regression - so we may as well just go ahead and fix it without too much thought.

@aik099
Copy link
Member Author

aik099 commented Dec 2, 2024

Created associated PRs. Ready for review.

@aik099
Copy link
Member Author

aik099 commented Dec 3, 2024

Closing, since everything is merged.

@aik099 aik099 closed this as completed Dec 3, 2024
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

3 participants