Skip to content

Commit f83e9f7

Browse files
committed
fix(UIHelper): make other than MUI based buttons clickable
Signed-off-by: Jan Richter <jrichter@redhat.com>
1 parent 685727f commit f83e9f7

5 files changed

Lines changed: 10 additions & 17 deletions

File tree

docs/changelog.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
## [2.1.0] - Current
5+
## [2.1.1] - Current
6+
7+
### Changed
8+
9+
- **UI Helper clickButton method**: Uses role based locators instead of CSS selectors. As such is now compatible with both MUI and BUI based buttons.
10+
11+
## [2.1.0]
612

713
### Added
814

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@red-hat-developer-hub/e2e-test-utils",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"description": "Test utilities for RHDH E2E tests",
55
"license": "Apache-2.0",
66
"repository": {

src/playwright/helpers/common.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { authenticator } from "otplib";
33
import { test, expect } from "@playwright/test";
44
import type { Browser, Page, TestInfo } from "@playwright/test";
55
import { SETTINGS_PAGE_COMPONENTS } from "../page-objects/page-obj.js";
6-
import { UI_HELPER_ELEMENTS } from "../page-objects/global-obj.js";
76
import * as path from "path";
87
import * as fs from "fs";
98
import { DEFAULT_USERS } from "../../deployment/keycloak/constants.js";
@@ -215,10 +214,6 @@ export class LoginHelper {
215214
}
216215
}
217216

218-
getButtonSelector(label: string): string {
219-
return `${UI_HELPER_ELEMENTS.MuiButtonLabel}:has-text("${label}")`;
220-
}
221-
222217
getLoginBtnSelector(): string {
223218
return 'MuiListItem-root li.MuiListItem-root button.MuiButton-root:has(span.MuiButton-label:text("Log in"))';
224219
}

src/playwright/helpers/ui-helper.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,11 @@ export class UIhelper {
9494
force: false,
9595
},
9696
) {
97-
const selector = `${UI_HELPER_ELEMENTS.MuiButtonLabel}`;
9897
const button = this.page
99-
.locator(selector)
100-
.getByText(label, { exact: options.exact })
98+
.getByRole("button", { name: label, exact: options.exact })
10199
.first();
100+
await button.click({ force: options.force });
102101

103-
if (options?.force) {
104-
await button.click({ force: true });
105-
} else {
106-
await button.click();
107-
}
108102
return button;
109103
}
110104

src/playwright/page-objects/global-obj.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ export const WAIT_OBJECTS = {
44
};
55

66
export const UI_HELPER_ELEMENTS = {
7-
MuiButtonLabel:
8-
'span[class^="MuiButton-label"],button[class*="MuiButton-root"]',
97
MuiToggleButtonLabel: 'span[class^="MuiToggleButton-label"]',
108
MuiBoxLabel: 'div[class*="MuiBox-root"] label',
119
MuiTableHead: 'th[class*="MuiTableCell-root"]',

0 commit comments

Comments
 (0)