Skip to content

Commit

Permalink
e2e bug fixes and code cleanup (#3599)
Browse files Browse the repository at this point in the history
* bug fixes and dead code cleanup

* add missing await
  • Loading branch information
DenysVuika authored Jan 12, 2024
1 parent 4a301d3 commit 53245d6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class UploadFilesDialog {

async closeUploadDialog(): Promise<void> {
if (await this.uploadDialog.isVisible()) {
this.closeUploadButton.click();
await this.closeUploadButton.click();
}
}
}
108 changes: 4 additions & 104 deletions projects/aca-testing-shared/src/utilities/test-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,9 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/

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<string> {
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<string> {
const present = await waitUntilElementIsVisible(elementFinder);
Expand All @@ -48,7 +36,7 @@ async function getText(elementFinder: ElementFinder): Promise<string> {
// 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();
}

Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -159,83 +137,13 @@ 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<any> {
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<any> {
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<any> {
return waitUntilElementHasValue(this.elementFinder, value);
}

/**
* Query whether the DOM element represented by this instance is enabled.
*/
async isEnabled(): Promise<boolean> {
return this.elementFinder.isEnabled();
}
/**
* Query whether the DOM element represented by this instance is disabled.
*/
async isDisabled(): Promise<boolean> {
return !(await this.elementFinder.isEnabled());
}

/**
* Test whether this element is currently displayed.
*/
async isDisplayed(): Promise<boolean> {
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<string> {
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.
*/
async getText(): Promise<string> {
return getText(this.elementFinder);
}

/**
* Gets the `value` attribute for the given input element
*
* @returns input value
*/
getInputValue(): Promise<string> {
return getInputValue(this.elementFinder);
}

/**
* Enter the text
*
Expand All @@ -244,12 +152,4 @@ export class TestElement {
async typeText(text: string): Promise<void> {
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);
}
}

0 comments on commit 53245d6

Please sign in to comment.