From 53245d6d6f494607f444fcf1b9060cb5a362a7bb Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Fri, 12 Jan 2024 07:09:08 -0500 Subject: [PATCH] e2e bug fixes and code cleanup (#3599) * bug fixes and dead code cleanup * add missing await --- .../components/dialog/upload-files-dialog.ts | 2 +- .../src/utilities/test-element.ts | 108 +----------------- 2 files changed, 5 insertions(+), 105 deletions(-) diff --git a/projects/aca-testing-shared/src/components/dialog/upload-files-dialog.ts b/projects/aca-testing-shared/src/components/dialog/upload-files-dialog.ts index 31a9d28766..fc3e005955 100644 --- a/projects/aca-testing-shared/src/components/dialog/upload-files-dialog.ts +++ b/projects/aca-testing-shared/src/components/dialog/upload-files-dialog.ts @@ -33,7 +33,7 @@ export class UploadFilesDialog { async closeUploadDialog(): Promise { if (await this.uploadDialog.isVisible()) { - this.closeUploadButton.click(); + await this.closeUploadButton.click(); } } } diff --git a/projects/aca-testing-shared/src/utilities/test-element.ts b/projects/aca-testing-shared/src/utilities/test-element.ts index 385d375fdd..20552f5eb9 100644 --- a/projects/aca-testing-shared/src/utilities/test-element.ts +++ b/projects/aca-testing-shared/src/utilities/test-element.ts @@ -22,21 +22,9 @@ * along with Alfresco. If not, see . */ -import { by, element, ElementFinder, protractor, $, browser } from 'protractor'; -import { clearSendKeys, click, getInputValue } from './browser-actions'; -import { - waitUntilElementHasValue, - waitUntilElementIsNotPresent, - waitUntilElementIsNotVisible, - waitUntilElementIsPresent, - waitUntilElementIsVisible -} from './browser-visibility'; - -async function getAttribute(elementFinder: ElementFinder, attribute: string): Promise { - await waitUntilElementIsPresent(elementFinder); - const attributeValue: string = await browser.executeScript(`return arguments[0].getAttribute(arguments[1])`, elementFinder, attribute); - return attributeValue || ''; -} +import { by, element, ElementFinder, $, browser } from 'protractor'; +import { clearSendKeys, click } from './browser-actions'; +import { waitUntilElementIsNotVisible, waitUntilElementIsPresent, waitUntilElementIsVisible } from './browser-visibility'; async function getText(elementFinder: ElementFinder): Promise { const present = await waitUntilElementIsVisible(elementFinder); @@ -48,7 +36,7 @@ async function getText(elementFinder: ElementFinder): Promise { // DO NOT REMOVE BUG sometime wrongly return empty text for cdk elements console.info(`Use backup get text script`); - text = await this.getTextScript(elementFinder); + text = await browser.executeScript(`return arguments[0].textContent`, elementFinder); return text?.trim(); } @@ -96,16 +84,6 @@ export class TestElement { return new TestElement(element(by.cssContainingText(selector, text))); } - /** - * Create a new instance with the element with specific HTML tag name - * - * @param selector the HTML tag name - * @returns test element wrapper - */ - static byTag(selector: string): TestElement { - return new TestElement(element(by.tagName(selector))); - } - /** * Performs a click on this element */ @@ -159,67 +137,6 @@ export class TestElement { } } - /** - * Waits until the element is present on the DOM of a page - * - * @param waitTimeout How long to wait for the condition to be true - */ - async waitPresent(waitTimeout?: number): Promise { - return waitUntilElementIsPresent(this.elementFinder, waitTimeout); - } - - /** - * Waits until the element is not attached to the DOM of a page - * - * @param waitTimeout How long to wait for the condition to be true - */ - async waitNotPresent(waitTimeout?: number): Promise { - return waitUntilElementIsNotPresent(this.elementFinder, waitTimeout); - } - - /** - * Waits until the given text is present in the element’s value - * - * @param value the text to check - */ - async waitHasValue(value: string): Promise { - return waitUntilElementHasValue(this.elementFinder, value); - } - - /** - * Query whether the DOM element represented by this instance is enabled. - */ - async isEnabled(): Promise { - return this.elementFinder.isEnabled(); - } - /** - * Query whether the DOM element represented by this instance is disabled. - */ - async isDisabled(): Promise { - return !(await this.elementFinder.isEnabled()); - } - - /** - * Test whether this element is currently displayed. - */ - async isDisplayed(): Promise { - try { - await this.elementFinder.isDisplayed(); - return true; - } catch { - return false; - } - } - - /** - * Query for the value of the given attribute of the element. - * - * @param attributeName The name of the attribute to query. - */ - async getAttribute(attributeName: string): Promise { - return getAttribute(this.elementFinder, attributeName); - } - /** * Get the visible (i.e. not hidden by CSS) innerText of this element, including sub-elements, without any leading or trailing whitespace. */ @@ -227,15 +144,6 @@ export class TestElement { return getText(this.elementFinder); } - /** - * Gets the `value` attribute for the given input element - * - * @returns input value - */ - getInputValue(): Promise { - return getInputValue(this.elementFinder); - } - /** * Enter the text * @@ -244,12 +152,4 @@ export class TestElement { async typeText(text: string): Promise { await clearSendKeys(this.elementFinder, text); } - - /** - * Clears the input using Ctrl+A and Backspace combination - */ - async clearInput() { - await this.elementFinder.clear(); - await this.elementFinder.sendKeys(' ', protractor.Key.CONTROL, 'a', protractor.Key.NULL, protractor.Key.BACK_SPACE); - } }