Raj*_*h G 17 javascript webautomation node.js playwright
我想使用铬而不是铬。我可以通过提供可执行路径在 puppeteer 中实现相同的目的。在 playwright 中它不起作用,因为浏览器类型参数仅支持“chromium、webkit、firefox”
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch({
headless: false,
executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
});
const context = await browser.newContext();
const page = await context.newPage();
await page.goto('http://whatsmyuseragent.org/');
await page.screenshot({ path: `example-${browserType}.png` });
})();
Run Code Online (Sandbox Code Playgroud)
在 1.19 中你可以使用 chrome。
browser = playwright.chromium.launch(channel="chrome")
Run Code Online (Sandbox Code Playgroud)
或者您可以简单地将其放入剧作家配置文件中,例如:
////
use: {
headless: true,
viewport: { width: 1600, height: 1000},
ignoreHTTPSErrors: true,
trace: 'on',
screenshot: 'on',
channel: "chrome",
video: 'on'
},
////
Run Code Online (Sandbox Code Playgroud)
更多关于https://playwright.dev/python/docs/browsers