import { baseUniDriverFactory, UniDriver, } from '@wix/wix-ui-test-utils/unidriver'; export const SearchableCollectionContentUniDriver = ( base: UniDriver, _body: UniDriver, ) => { return { ...baseUniDriverFactory(base), getMatchAtIndex: async (index: number) => { // Find all spans with highlighter classes (contains "Highlighter" in the class name) // Based on the HTML structure: a const highlightedSpans = await base.$$('span[class*="Highlighter"]'); const spanCount = await highlightedSpans.count(); // Check if the index is valid if (index < 0 || index >= spanCount) { throw new Error( `Match index ${index} is out of range. Found ${spanCount} matches.`, ); } // Get the span at the specified index const span = await highlightedSpans.at(index); const text = await span.text(); return text?.trim() || ''; }, getNumberOfMatches: async () => { // Count all spans with highlighter classes const highlightedSpans = await base.$$('span[class*="Highlighter"]'); return highlightedSpans.count(); }, }; };