本文整理汇总了TypeScript中chrome-remote-interface.Version函数的典型用法代码示例。如果您正苦于以下问题:TypeScript Version函数的具体用法?TypeScript Version怎么用?TypeScript Version使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Version函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: test
test('screenshot by selector', async t => {
const version = await CDP.Version()
const versionMajor = parseInt(/Chrome\/(\d+)/.exec(version['User-Agent'])[1])
// clipping will only work on chrome 61+
const chromeless = new Chromeless({ launchChrome: false })
const screenshot = await chromeless.goto(testUrl).screenshot('img')
await chromeless.end()
const png = await getPngMetaData(screenshot)
t.is(png.width, versionMajor > 60 ? 512 : 1440)
t.is(png.height, versionMajor > 60 ? 512 : 900)
})
开发者ID:13768324554,项目名称:chromeless,代码行数:14,代码来源:util.test.ts
示例2: setViewport
private async setViewport(client: Client) {
const { viewport = {} } = this.options
const config: any = {
deviceScaleFactor: 1,
mobile: false,
scale: viewport.scale || 1,
fitWindow: false, // as we cannot resize the window, `fitWindow: false` is needed in order for the viewport to be resizable
}
const { host, port } = this.options.cdp
const versionResult = await CDP.Version({ host, port })
const isHeadless = versionResult['User-Agent'].includes('Headless')
if (viewport.height && viewport.width) {
config.height = viewport.height
config.width = viewport.width
} else if (isHeadless) {
// just apply default value in headless mode to maintain original browser viewport
config.height = 900
config.width = 1440
} else {
config.height = await evaluate(
client,
(() => window.innerHeight).toString(),
)
config.width = await evaluate(
client,
(() => window.innerWidth).toString(),
)
}
await client.Emulation.setDeviceMetricsOverride(config)
await client.Emulation.setVisibleSize({
width: config.width,
height: config.height,
})
}
开发者ID:13768324554,项目名称:chromeless,代码行数:38,代码来源:local.ts
注:本文中的chrome-remote-interface.Version函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论