木偶在非无头模式下打开一个空选项卡 [英] Puppeteer opens an empty tab in non-headless mode
问题描述
运行puppeteer(最新版本为npm-0.13.0)并将args传递给
When running puppeteer(last version from npm - 0.13.0) and passing args to
puppeteer.launch({headless:false})
首先打开带有空白页面的镶边,然后在第二个标签中打开脚本中的实际页面.
the chrome is opened with an empty page as a first tab and opens the actual page from the script in the second tab.
常量页面=等待browser.newPage();
这是预期的行为吗?还是一个错误?
const page = await browser.newPage();
Is it an expected behavior? Or a bug?
推荐答案
是的,这是预期的行为.它的功能与打开chrome浏览器完全相同.如果您关闭了第一个标签页,则浏览器将像使用chrome浏览器一样关闭.必须至少打开一个选项卡,浏览器才能保持打开状态.如果您在启动浏览器时使用 await browser.pages
,它将返回当前打开的所有页面,应为1 about:blank page.
Yes that's expected behavior. It works exactly as opening a chrome browser. If you closed that first tab the browser will close just as using the chrome browser. There needs to be at least one tab open for the browser to remain open. If you use await browser.pages
upon launching the browser, that will return all the pages open currently, which should be 1 about:blank page.
这篇关于木偶在非无头模式下打开一个空选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!