From 51b7cbaba2a4d3ea51deb18398de14e484b53815 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Mon, 26 Jul 2021 19:02:53 +0200 Subject: [PATCH] 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. (cherry picked from commit 0742babf332b3ff7e55e8e81900fdc69d67a3fc6) --- .../testing/selenium-webdriver/selenium-web-driver-element.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cdk/testing/selenium-webdriver/selenium-web-driver-element.ts b/src/cdk/testing/selenium-webdriver/selenium-web-driver-element.ts index 2f7217ddf994..324fe339acdc 100644 --- a/src/cdk/testing/selenium-webdriver/selenium-web-driver-element.ts +++ b/src/cdk/testing/selenium-webdriver/selenium-web-driver-element.ts @@ -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. */