cypress-cucumber-steps
Version:
Cypress Cucumber step definitions
21 lines (20 loc) • 435 B
text/typescript
/**
* Get first Cypress element by display value.
*
* @param element - Element name.
* @param value - Display value.
* @returns - Cypress element.
* @private
*/
export function getByDisplayValue(
element: 'input' | 'textarea',
value: string,
) {
return cy
.get(`${element}:visible`)
.filter(
(index, element: HTMLInputElement) =>
Cypress.$(element).val()?.toString() === value,
)
.first();
}