diff --git a/src/app-layout/__integ__/awsui-applayout-sticky.test.ts b/src/app-layout/__integ__/awsui-applayout-sticky.test.ts index a4386ae556..62e3340a0e 100644 --- a/src/app-layout/__integ__/awsui-applayout-sticky.test.ts +++ b/src/app-layout/__integ__/awsui-applayout-sticky.test.ts @@ -11,12 +11,8 @@ const wrapper = createWrapper().findAppLayout(); const stickyToggleSelector = createWrapper().findFlashbar().findItems().get(1).findActionButton().toSelector(); class AppLayoutStickyPage extends BasePageObject { - async isNotificationVisible() { - const elements = await this.browser.$$(wrapper.findNotifications().toSelector()); - if (elements.length === 0) { - return false; - } - return elements[0].isDisplayedInViewport(); + isNotificationVisible() { + return this.isDisplayedInViewport(wrapper.findNotifications().toSelector()); } async toggleStickiness() { diff --git a/src/code-editor/__integ__/code-editor.test.ts b/src/code-editor/__integ__/code-editor.test.ts index 00bcf06f55..e04cac9acb 100644 --- a/src/code-editor/__integ__/code-editor.test.ts +++ b/src/code-editor/__integ__/code-editor.test.ts @@ -48,9 +48,6 @@ class CodeEditorPageObject extends BasePageObject { const { height } = await this.getBoundingBox(`#${elementId} .${styles['resizable-box']}`); return height; } - async isDisplayedInViewport(selector: string) { - return (await this.browser.$(selector)).isDisplayedInViewport(); - } async getEventValue() { return (await this.browser.$(`#event-content`)).getText(); } diff --git a/src/container/__integ__/awsui-applayout-sticky.test.ts b/src/container/__integ__/awsui-applayout-sticky.test.ts index 7ca90af09c..d840773e4a 100644 --- a/src/container/__integ__/awsui-applayout-sticky.test.ts +++ b/src/container/__integ__/awsui-applayout-sticky.test.ts @@ -18,12 +18,8 @@ const headerSelector = '#b #h'; const scrollableDivSelector = '#scrollable-div'; class AppLayoutStickyPage extends BasePageObject { - async isNotificationVisible() { - const elements = await this.browser.$$(appLayoutWrapper.findNotifications().toSelector()); - if (elements.length === 0) { - return false; - } - return elements[0].isDisplayedInViewport(); + isNotificationVisible() { + return this.isDisplayedInViewport(appLayoutWrapper.findNotifications().toSelector()); } async toggleStickiness() { diff --git a/src/table/__integ__/performance-marks.test.ts b/src/table/__integ__/performance-marks.test.ts index d401f6ae59..38c2897c9a 100644 --- a/src/table/__integ__/performance-marks.test.ts +++ b/src/table/__integ__/performance-marks.test.ts @@ -1,5 +1,6 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 + import { BasePageObject } from '@cloudscape-design/browser-test-tools/page-objects'; import useBrowser from '@cloudscape-design/browser-test-tools/use-browser'; @@ -17,7 +18,10 @@ function setupTest( const marks = await browser.execute(() => performance.getEntriesByType('mark') as PerformanceMark[]); return marks.filter(m => m.detail?.source === 'awsui'); }; - const getElementByPerformanceMark = (id: string) => browser.$(`[data-analytics-performance-mark="${id}"]`); + const getElementByPerformanceMark = async (id: string) => { + const element = await browser.$(`[data-analytics-performance-mark="${id}"]`); + return element; + }; await testFn({ page, getMarks, getElementByPerformanceMark }); }); diff --git a/src/tag-editor/__integ__/page/tag-editor-page.ts b/src/tag-editor/__integ__/page/tag-editor-page.ts index be23d81b72..ccc63f6989 100644 --- a/src/tag-editor/__integ__/page/tag-editor-page.ts +++ b/src/tag-editor/__integ__/page/tag-editor-page.ts @@ -203,9 +203,9 @@ export default class TagEditorPage extends BasePageObject { } async getTags() { - const elements = await this.browser.$$(tagEditorWrapper.findRows().toSelector()); + const elementsCount = await this.getElementsCount(tagEditorWrapper.findRows().toSelector()); const tags = []; - for (let index = 1; index <= elements.length; index++) { + for (let index = 1; index <= elementsCount; index++) { tags.push(await this.getTag(index)); } return tags; diff --git a/src/theming/__integ__/index.test.ts b/src/theming/__integ__/index.test.ts index 1a27ad4aec..642cbd06dc 100644 --- a/src/theming/__integ__/index.test.ts +++ b/src/theming/__integ__/index.test.ts @@ -20,17 +20,18 @@ class ThemingPage extends BasePageObject { setSecondaryTheme() { return this.click('[data-testid="set-secondary"]'); } - async getCSSProperty(selector: string, property: string) { + async getCSSProperty(selector: string, property: string): Promise { const elem = await this.browser.$(selector); - return this.browser.getElementCSSValue(elem.elementId, property); + const propertyValue = await this.browser.getElementCSSValue(elem.elementId, property); + return propertyValue; } - getButtonBackgroundColor() { + getButtonBackgroundColor(): Promise { return this.getCSSProperty(wrapper.findButton().toSelector(), 'background-color'); } - getLinkTextColor() { + getLinkTextColor(): Promise { return this.getCSSProperty(wrapper.findLink().toSelector(), 'color'); } - getFakeLinkTextColor() { + getFakeLinkTextColor(): Promise { return this.getCSSProperty(wrapper.find('a[data-testid=element-color-text-link-default]').toSelector(), 'color'); } } diff --git a/src/wizard/__integ__/wizard.test.ts b/src/wizard/__integ__/wizard.test.ts index 6636f5094a..f2c0ede4b0 100644 --- a/src/wizard/__integ__/wizard.test.ts +++ b/src/wizard/__integ__/wizard.test.ts @@ -14,12 +14,8 @@ class WizardPageObject extends BasePageObject { resetFocus() { return this.click('#focus-reset'); } - async isContentDisplayedInViewport() { - const elements = await this.browser.$$('#content-text'); - if (elements.length === 0) { - return false; - } - return elements[0].isDisplayedInViewport(); + isContentDisplayedInViewport() { + return this.isDisplayedInViewport('#content-text'); } toggleScrollableContainer() { return this.click(createWrapper().findToggle().findNativeInput().toSelector());