Fix and improve basline tests

This commit is contained in:
adilallo
2025-08-30 13:37:55 -06:00
parent de04405de7
commit c20f704ccf
8 changed files with 559 additions and 132 deletions
+35
View File
@@ -0,0 +1,35 @@
import { Locator, Page } from "@playwright/test";
export async function findVisibleButton(
page: Page,
text: string
): Promise<Locator> {
const buttons = page.locator(`button:has-text("${text}")`);
const buttonCount = await buttons.count();
for (let i = 0; i < buttonCount; i++) {
const button = buttons.nth(i);
if (await button.isVisible()) {
return button;
}
}
throw new Error(`No visible button with text "${text}" found`);
}
export async function findVisibleElement(
page: Page,
selector: string
): Promise<Locator> {
const elements = page.locator(selector);
const elementCount = await elements.count();
for (let i = 0; i < elementCount; i++) {
const element = elements.nth(i);
if (await element.isVisible()) {
return element;
}
}
throw new Error(`No visible element with selector "${selector}" found`);
}