如何将无头从假变成真? [p]

时间:2018-08-15 04:51:17

标签: puppeteer

如何将无头从假变成真? 如何隐藏浏览器?

const browser = await puppeteer.launch({headless: false})
const page = await browser.newPage();
await page.goto(LOGIN_URL, { "waitUntil": "networkidle2" });
await page.evaluate((a) => {
   $('input[name="username"]').val(a.username)
   $('input[name="password"]').val(a.password)
}, {username, password})
 // I want to hide the browser
 // do something
await browser.close();

2 个答案:

答案 0 :(得分:0)

使用此:

private void Form1_Load(object sender, EventArgs e) { textBox1.KeyDown += new KeyEventHandler(tb_KeyDown); } static void tb_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { MessageBox.Show(" some junk"); } }

答案 1 :(得分:0)

在运行时无法将浏览器隐藏在puppeteer中-这是因为Chromium只能无头或无头启动。

但是在一个脚本中,您可以先运行无头浏览器,将其关闭然后再打开无头浏览器:

let browser = await puppeteer.launch({headless : false});
// 1. Enter requisites, log in to a site
// 2. Save cookies
await browser.close();
browser = await puppeteer.launch({headless : true});
// 3. Load cookies
// 4. Go and do headless stuff