ok
Some checks failed
CI / validate (push) Has been cancelled

This commit is contained in:
isopropilick
2026-08-27 15:00:50 -06:00
parent b35387d841
commit 896c3a121a
19 changed files with 569 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
import { $, $$ } from '@wdio/globals';
import { dictionary } from './index.js';
type SelectorNode = string | Record<string, unknown>;
export function getSelector(route: string): string {
const value = route.split('.').reduce<unknown>((current, segment) => {
if (!current || typeof current !== 'object') return undefined;
return (current as Record<string, unknown>)[segment];
}, dictionary);
if (typeof value !== 'string' || value.trim() === '') {
throw new Error(`Selector route "${route}" does not resolve to a selector string.`);
}
return value;
}
export async function getElement(route: string, shouldBeVisible = true): Promise<ReturnType<typeof $>> {
const element = $(getSelector(route));
if (shouldBeVisible) {
await element.waitForExist({ timeout: 60_000 });
await element.waitForDisplayed({ timeout: 60_000 });
} else {
await element.waitForDisplayed({ timeout: 60_000, reverse: true });
}
return element;
}
export async function getElements(route: string): Promise<ReturnType<typeof $$>> {
const selector = getSelector(route);
const firstElement = $(selector);
await firstElement.waitForExist({ timeout: 60_000 });
await firstElement.waitForDisplayed({ timeout: 60_000 });
return $$(selector);
}
export type { SelectorNode };

7
test/selectors/index.ts Normal file
View File

@@ -0,0 +1,7 @@
import loginSelectors from './page-objects/login.js';
import secureSelectors from './page-objects/secure.js';
export const dictionary = {
...loginSelectors,
...secureSelectors,
};

View File

@@ -0,0 +1,9 @@
const loginSelectors = {
loginPage: {
inputUsername: '#username',
inputPassword: '#password',
submitButton: 'button[type="submit"]',
},
};
export default loginSelectors;

View File

@@ -0,0 +1,7 @@
const secureSelectors = {
securePage: {
flashAlert: '#flash',
},
};
export default secureSelectors;