代码之家  ›  专栏  ›  技术社区  ›  jtbandes

可以加载吗chrome://gpu使用木偶演员?

  •  0
  • jtbandes  · 技术社区  · 7 年前

    我在用木偶师拍摄一些页面的截图。我想检查GPU/WebGL支持,但是当我使用 await page.goto("chrome://gpu") ,我得到这个错误:

    Error: Navigation failed because browser has disconnected!
        at CDPSession.LifecycleWatcher._eventListeners.helper.addEventListener (/app/node_modules/puppeteer/lib/LifecycleWatcher.js:47:107)
        at emitNone (events.js:106:13)
        at CDPSession.emit (events.js:208:7)
        at CDPSession._onClosed (/app/node_modules/puppeteer/lib/Connection.js:215:10)
        at Connection._onClose (/app/node_modules/puppeteer/lib/Connection.js:138:15)
        at WebSocketTransport._ws.addEventListener.event (/app/node_modules/puppeteer/lib/WebSocketTransport.js:45:22)
        at WebSocket.onClose (/app/node_modules/ws/lib/event-target.js:124:16)
        at emitTwo (events.js:126:13)
        at WebSocket.emit (events.js:214:7)
        at WebSocket.emitClose (/app/node_modules/ws/lib/websocket.js:180:10)
      -- ASYNC --
        at Frame.<anonymous> (/app/node_modules/puppeteer/lib/helper.js:108:27)
        at Page.goto (/app/node_modules/puppeteer/lib/Page.js:662:49)
        at Page.<anonymous> (/app/node_modules/puppeteer/lib/helper.js:109:23)
        at main (/app/index.js:21:16)
        at <anonymous>
        at process._tickCallback (internal/process/next_tick.js:188:7)
    

    如果我改用 await page.evaluate(() => window.location.href = "chrome://gpu") ,该页面会在控制台中记录一条错误消息

    不允许加载本地资源:chrome://gpu/

    有没有办法从Puppeter加载GPU状态页面?

    1 回复  |  直到 7 年前
        1
  •  1
  •   vsemozhebuty    7 年前

    我无法在Windows 7 x64上复制最后一个tip of tree Puppeter版本:

    'use strict';
    
    const puppeteer = require('puppeteer');
    
    (async function main() {
      try {
        const browser = await puppeteer.launch();
        const [page] = await browser.pages();
    
        await page.goto('chrome://gpu');
    
        const data = await page.evaluate(() =>
          [...document.querySelectorAll('h3')].map(({ innerText }) => innerText)
        );
    
        console.log(data);
    
        await browser.close();
      } catch (err) {
        console.error(err);
      }
    })();
    

    输出:

    [ 'Graphics Feature Status',
      'Driver Bug Workarounds',
      'Problems Detected',
      'Version Information',
      'Driver Information',
      'Compositor Information',
      'GpuMemoryBuffers Status',
      'Display(s) Information',
      'Video Acceleration Information',
      'Diagnostics',
      'Driver Information for Hardware GPU',
      'Graphics Feature Status for Hardware GPU',
      'Driver Bug Workarounds for Hardware GPU',
      'Problems Detected for Hardware GPU',
      'Log Messages' ]