使用 launchPersistentContext
即可,需提供一个文件夹存放 cookie 等数据
// @ts-check
const { chromium } = require("playwright");
const path = require('path');
(async () => {
// Make sure to run headed.
const browser = await chromium.launchPersistentContext(path.resolve("./userData"), {
executablePath: "C:/Program Files/Google/Chrome/Application/chrome.exe",
headless: false,
});
const [page] = browser.pages();
})();