Desktop boot check: say why a tab could not be opened

This commit is contained in:
CRTkafa 2026-10-23 10:36:38 +08:00
parent 8106d7c9a2
commit 83bb9a621e

View file

@ -249,8 +249,13 @@ async function clickTab(page: Page, id: string, o: { timeout?: number } = {}): P
await tab.waitFor({ state: 'attached', timeout: o.timeout });
if (await tab.isVisible()) { await tab.click(o); return; }
const label = ((await tab.textContent()) ?? '').replace(/\d+$/, '').trim();
await page.locator('.ds-tab-more').click(o);
await page.locator('.ds-menu [role="menuitem"]', { hasText: label }).first().click(o);
try {
await page.locator('.ds-tab-more').click(o);
await page.locator('.ds-menu [role="menuitem"]', { hasText: label }).first().click(o);
} catch (e) {
const why = await page.evaluate(() => JSON.stringify({ more: document.querySelectorAll('.ds-tab-more').length, menu: [...document.querySelectorAll('.ds-menu [role^="menuitem"]')].map(x => x.textContent), w: innerWidth }));
throw new Error(`${String(e).split('\n')[0]} (${label}; ${why})`);
}
}
async function state(page: Page) {