import { chromium } from "playwright";
import uniqueRandomArray from "unique-random-array";
import userAgents from "top-user-agents";
import setupRoute from "./setupRoute.js";

const browser = await chromium.launch({
    userAgent: uniqueRandomArray(userAgents)(),
    headless: false,
    devtools: true,
    proxy: {
        server: "190.2.130.11:12796",
        username: "12932405-res-country-MX-session-1",
        password: "1mrmt4wqg5",
    },
});

const page = await browser.newPage();

await setupRoute(page);

await page.goto("https://www.pcoptimum.ca/login");

await page.waitForURL("https://accounts.pcid.ca/login", { timeout: 60000 });

await page.fill('input[id="email"]', "xiongzhu1@gmail.com");
await page.fill('input[id="password"]', "x1ongDrew1");

await page.click('button:has-text("Sign in")');
