From 9a2c69f13c97a7466fb815ac17f66dbbe8479bb8 Mon Sep 17 00:00:00 2001 From: escapedcat Date: Mon, 11 Jul 2022 15:17:28 +0800 Subject: [PATCH] test: update ext-id finding #1051 --- tests/e2e/helpers/loadExtension.ts | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/tests/e2e/helpers/loadExtension.ts b/tests/e2e/helpers/loadExtension.ts index 7f2092e532..7dce6fa986 100644 --- a/tests/e2e/helpers/loadExtension.ts +++ b/tests/e2e/helpers/loadExtension.ts @@ -26,23 +26,17 @@ export const loadExtension = async () => { // trick to bring the new welcome page to the front await delay(1000); + const page = await browser.newPage(); await page.setViewport({ width: 1366, height: 768 }); - // get extensionId - // https://github.com/microsoft/playwright/issues/5593#issuecomment-949813218 - await page.goto("chrome://inspect/#extensions"); - // https://techoverflow.net/2019/01/26/puppeteer-get-text-content-inner-html-of-an-element/ - // TODO: check if just `page.$('...') will work because it should: - // https://puppeteer.github.io/puppeteer/docs/puppeteer.elementhandle - const url = await page.evaluate( - () => - ( - document.querySelector( - '#extensions-list div[class="url"]' - ) as HTMLElement - ).innerText + const targets = await browser.targets(); + const albyExtensionServiceWorkerTarget = targets.find( + (target) => target.url().indexOf("chrome-extension") > -1 ); + if (!albyExtensionServiceWorkerTarget) return; + + const url = albyExtensionServiceWorkerTarget.url(); const [, , extensionId] = url.split("/"); const extensionOptionHtml = "welcome.html";