Skip to content

Commit 0742bab

Browse files
authored
fix(cdk/testing): extract hidden text in web driver element (#23239)
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.
1 parent 24c35a4 commit 0742bab

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/cdk/testing/selenium-webdriver/selenium-web-driver-element.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ export class SeleniumWebDriverElement implements TestElement {
136136
if (options?.exclude) {
137137
return this._executeScript(_getTextWithExcludedElements, this.element(), options.exclude);
138138
}
139-
return this.element().getText();
139+
// We don't go through the WebDriver `getText`, because it excludes text from hidden elements.
140+
return this._executeScript(
141+
(element: Element) => (element.textContent || '').trim(), this.element());
140142
}
141143

142144
/** Gets the value for the given attribute from the element. */

0 commit comments

Comments
 (0)