import { chromium } from "playwright"; const browser = await chromium.launch({ headless: false, devtools: true, }); const page = await browser.newPage(); await page.route("**/*", async (route, request) => { console.log(request.url()); const resourceType = route.request().resourceType(); if (["image", "font"].includes(resourceType)) { route.abort(); } else if (/\/sp\/h/.test(request.url())) { route.abort(); } else { route.continue(); } }); await page.goto("https://www.pcoptimum.ca/"); const link = await page.$('a > span:has-text("sign in")'); link.click(); await page.waitForURL("https://accounts.pcid.ca/login"); await page.fill('input[id="email"]', "linxiaojoe@hotmail.com"); await page.fill('input[id="password"]', "Andy123456$"); await page.click('button:has-text("Sign in")'); console.log("xxx"); await page.route("**/points", async (route, request) => { console.log(request.url()); await route.continue(); const response = await route.fetch(); console.log(await response.json()); }); try { await page.waitForURL("https://www.pcoptimum.ca/dashboard"); } catch (error) { console.log(error); console.log(page.url()); await page.screenshot({ path: "error.png" }); process.exit(1); } console.log("Logged in"); await page.waitForTimeout(5000); const element = await page.$(".points-overview-balance"); const text = await element.textContent(); console.log(text);