Skip to content

Commit

Permalink
fix(cdk/testing): extract hidden text in web driver element (#23239)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
crisbeto authored and mmalerba committed Jul 26, 2021
1 parent 2cc11e6 commit 51b7cba
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ export class SeleniumWebDriverElement implements TestElement {
if (options?.exclude) {
return this._executeScript(_getTextWithExcludedElements, this.element(), options.exclude);
}
return this.element().getText();
// We don't go through the WebDriver `getText`, because it excludes text from hidden elements.
return this._executeScript(
(element: Element) => (element.textContent || '').trim(), this.element());
}

/** Gets the value for the given attribute from the element. */
Expand Down

0 comments on commit 51b7cba

Please sign in to comment.