是否有方法为devtools窗口提供默认宽度。就像现在一样,当我启动chrome并打开DevTools时,它的宽度大约是窗口宽度的一半。理想情况下,我会做这样的事情
$> /Applications/Google Chrome.app/Contents/MacOS/"Google Chrome"
--devtools-width=300告诉它宽度是多少。
为了给出一些上下文,我正在运行Puppeteer,在我的例子中,它在启动浏览器时打开DevTools。但对我来说太宽了,我每次都要调整尺寸。这是我的配置:
await puppeteer.launch({
headless: false,
devtools: true,
defaultViewport: null,
executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
args: [
'--debug-devtools',
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-web-security',
'--allow-running-insecure-content',
'--disable-notifications',
'--window-size=1920,1080'
]
});但我认为这不是木偶师的问题。
发布于 2019-10-20 13:39:58
将木偶师-额外与木偶师.插件.用户偏好一起使用并指定splitViewState。
package.json依赖关系:
"puppeteer": "^1.20.0",
"puppeteer-extra": "^2.1.3",
"puppeteer-extra-plugin-user-data-dir": "^2.1.2",
"puppeteer-extra-plugin-user-preferences": "^2.1.2"用法:
const puppeteer = require('puppeteer-extra');
const ppUserPrefs = require('puppeteer-extra-plugin-user-preferences');
puppeteer.use(ppUserPrefs({
userPrefs: {
devtools: {
preferences: {
'InspectorView.splitViewState': JSON.stringify({
vertical: {size: 300},
horizontal: {size: 0},
}),
uiTheme: '"dark"',
},
},
},
}));
puppeteer.launch({
headless: false,
devtools: true,
defaultViewport: null,
args: [
'--window-size=1920,1080',
],
});要查看完整列表,请在浏览器配置文件目录中复制Preferences的内容,并将其格式化为任何JSON,然后在其中查找devtools和preferences。
https://stackoverflow.com/questions/58473161
复制相似问题