"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findLocatorInPaginatedList = void 0;
const sleep_1 = require("./sleep");
async function findLocatorInPaginatedList(page, locator) {
    const maxPage = 3;
    const nextButton = page.getByRole('button', { name: 'Next page' });
    const cluster = locator.first();
    for (let i = 0; i < maxPage; i++) {
        if ((await cluster.count()) > 0) {
            return true;
        }
        if (!(await nextButton.isVisible()) || (await nextButton.isDisabled())) {
            break;
        }
        await nextButton.click();
        await (0, sleep_1.sleep)(1000);
    }
    throw new Error(`Not found in paginated table.`);
}
exports.findLocatorInPaginatedList = findLocatorInPaginatedList;
