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

fix(cdk/testing): protractor element not extracting hidden text #21540

Merged
merged 1 commit into from Jul 23, 2021

Conversation

@crisbeto
Copy link
Member

@crisbeto crisbeto commented Jan 11, 2021

We use Protractor's getText method to extract text, but the problem is that it's likely based on HTMLElement.innerText which excludes text from hidden elements.

These changes switch to using textContent to bring the behavior in-line with the UnitTestElement.

@google-cla google-cla bot added the cla: yes label Jan 11, 2021
We use Protractor's `getText` method to extract text, but the problem is that it's likely based
on `HTMLElement.innerText` which excludes text from hidden elements.

These changes switch to using `textContent` to bring the behavior in-line with the `UnitTestElement`.
@crisbeto crisbeto force-pushed the protractor-hidden-text branch from 8739a98 to 9187032 Jan 11, 2021
@crisbeto crisbeto marked this pull request as ready for review Jan 11, 2021
Copy link
Member

@jelbourn jelbourn left a comment

LGTM

@jelbourn
Copy link
Member

@jelbourn jelbourn commented Jan 11, 2021

Caretaker note: this has a chance of breaking some e2e tests, but I suspect it to be somewhat unlikely

@mmalerba
Copy link
Contributor

@mmalerba mmalerba commented Feb 17, 2021

There were only a few failures as a result of this, but investigating one of them uncovered something that I guess is more of a problem with the stepper. The stepper leaves steps that are not visible in the DOM. There is a project using MatButtonHarness to get the "Next" button, but with this change it always gets the button for the first step, regardless of what step is shown. Any thoughts on what the right solution to this is?

@crisbeto
Copy link
Member Author

@crisbeto crisbeto commented Feb 17, 2021

I suppose to correct way to handle it would be to use a selector. They would've had this issue if they were running the test using TestBed as well.

@mmalerba
Copy link
Contributor

@mmalerba mmalerba commented Feb 17, 2021

Isn't a selector just going to have the same problem? I didn't really see any classes that identify the currently visible step to select on

@crisbeto
Copy link
Member Author

@crisbeto crisbeto commented Feb 18, 2021

Doesn't look like we have any classes that would identify it so the stepper harness uses aria-selected for it. Maybe something like MatButtonHarness.with({text: 'Next', ancestor: '[aria-selected="true"]'})?

@mmalerba
Copy link
Contributor

@mmalerba mmalerba commented Feb 18, 2021

Ok that seems reasonable, or better yet maybe I can just change their test to use the stepper harness

@mmalerba mmalerba merged commit 26366e7 into angular:master Jul 23, 2021
16 checks passed
mmalerba added a commit that referenced this issue Jul 23, 2021
We use Protractor's `getText` method to extract text, but the problem is that it's likely based
on `HTMLElement.innerText` which excludes text from hidden elements.

These changes switch to using `textContent` to bring the behavior in-line with the `UnitTestElement`.

(cherry picked from commit 26366e7)
crisbeto added a commit to crisbeto/material2 that referenced this issue Jul 24, 2021
In angular#21540 we added support for extracting text from hidden elements in Protractor, but before the PR could be merged, we introduced the WebDriver environment which didn't include the fix and is failing the e2e tests.

These changes port over the fix.
mmalerba pushed a commit that referenced this issue Jul 26, 2021
In #21540 we added support for extracting text from hidden elements in Protractor, but before the PR could be merged, we introduced the WebDriver environment which didn't include the fix and is failing the e2e tests.

These changes port over the fix.
mmalerba added a commit that referenced this issue Jul 26, 2021
In #21540 we added support for extracting text from hidden elements in Protractor, but before the PR could be merged, we introduced the WebDriver environment which didn't include the fix and is failing the e2e tests.

These changes port over the fix.

(cherry picked from commit 0742bab)
@angular-automatic-lock-bot
Copy link

@angular-automatic-lock-bot angular-automatic-lock-bot bot commented Aug 23, 2021

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Aug 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants