@augment-vir/test
Version:
A universal testing suite that works with Mocha style test runners _and_ Node.js's built-in test runner.
20 lines (19 loc) • 658 B
JavaScript
import { assertTestContext, TestEnv, } from '../augments/universal-testing-suite/universal-test-context.js';
/**
* Find the matching (or first) "option" or "menuitem" element. Tries both roles and returns
* whichever one is found.
*
* @category Internal
*/
export function getMenuOption(testContext, options) {
assertTestContext(testContext, TestEnv.Playwright);
const baseLocator = testContext.page
.getByRole('option', options)
.or(testContext.page.getByRole('menuitem', options));
if (options && 'nth' in options) {
return baseLocator.nth(options.nth);
}
else {
return baseLocator.first();
}
}