Skip to content

Commit

Permalink
chore: Supporting webdriverio v9 migration (#2735)
Browse files Browse the repository at this point in the history
  • Loading branch information
pan-kot authored Sep 23, 2024
1 parent 1ebdd78 commit 67b55ef
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 29 deletions.
8 changes: 2 additions & 6 deletions src/app-layout/__integ__/awsui-applayout-sticky.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
3 changes: 0 additions & 3 deletions src/code-editor/__integ__/code-editor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
8 changes: 2 additions & 6 deletions src/container/__integ__/awsui-applayout-sticky.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
6 changes: 5 additions & 1 deletion src/table/__integ__/performance-marks.test.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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 });
});
Expand Down
4 changes: 2 additions & 2 deletions src/tag-editor/__integ__/page/tag-editor-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 6 additions & 5 deletions src/theming/__integ__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
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<string> {
return this.getCSSProperty(wrapper.findButton().toSelector(), 'background-color');
}
getLinkTextColor() {
getLinkTextColor(): Promise<string> {
return this.getCSSProperty(wrapper.findLink().toSelector(), 'color');
}
getFakeLinkTextColor() {
getFakeLinkTextColor(): Promise<string> {
return this.getCSSProperty(wrapper.find('a[data-testid=element-color-text-link-default]').toSelector(), 'color');
}
}
Expand Down
8 changes: 2 additions & 6 deletions src/wizard/__integ__/wizard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 67b55ef

Please sign in to comment.