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

Use "innerText" attribute in getText() method #362

Closed
wants to merge 2 commits into from

Conversation

yyss8
Copy link

@yyss8 yyss8 commented Feb 17, 2023

Hi, we recently moved the tests of our Drupal site from using chrome-mink-driver to MinkSelenium2Driver and noticing some of the tests are failing due to an empty string being returned when trying to assert the title of the page.

We found a similar issue here #193 and it seems to be an upstream issue with Selenium?

It also lead us to this stackoverflow answer and which recommends to use innerText attribute to retrieve the text of the element.

Similar issue reported on Drupal.org

@aik099
Copy link
Member

aik099 commented Feb 18, 2023

@yyss8 can you please reference the issue on the Selenium side?

I don't understand what Selenium the bug prevents the ->text() method from working on some nodes.

@mvorisek
Copy link
Contributor

mvorisek commented Mar 1, 2023

I belive the problem is #327. I would be happy @aik099 if my original PR can be reconsidered, as the getText() will be than implemented consistently like getHtml().

@aik099
Copy link
Member

aik099 commented May 11, 2023

@yyss8 , would it be possible to rewrite your tests to perform actions/assertions based on user possible actions in the Web Browser (e.g. not checking the text of the elements, that aren't visible on the page)?

@mvorisek
Copy link
Contributor

Here is how I fixed it in my fork: atk4@05e2230

https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText innerText property is well defined:

As a getter, it approximates the text the user would get if they highlighted the contents of the element with the cursor and then copied it to the clipboard.

If the element itself is not being rendered (for example, is detached from the document or is hidden from view), the returned value is the same as the Node.textContent property.

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

Successfully merging this pull request may close these issues.

3 participants