title: Chrome DevTools Protocol: switch 'active' frame
body: <p>I'm using Chrome Headless and <code>chrome-remote-interface</code> <strong>npm</strong> package</p>
  
  <pre><code>const chromeLauncher = require('chrome-launcher')
  const CDP = require('chrome-remote-interface')
  const fs = require('fs')
  
  async function launchChrome() {
    return chromeLauncher.launch({
      port: 9222,
      chromeFlags: ['--disable-gpu', '--headless']
    })
  }
  
  (async function () {
      const chrome = await launchChrome()
      const client = await CDP({port: 9222})
      const {Page} = client
      await Page.enable()
      await Page.navigate({url: 'http://...'})
      await Page.loadEventFired()
      const {data} = await Page.captureScreenshot()
      fs.writeFileSync('screenshot.png', Buffer.from(data, 'base64'))
      await protocol.close()
      await chrome.kill()
  })()
  </code></pre>
  
  <p>But the page I'm loading contains an <strong>iframe</strong> and I want to perform some actions inside it (<strong>click</strong> some elements or access them via <strong>DOM.querySelector</strong>) before taking the screenshot. </p>
  
  <p>Is it possible to switch current 'active' frame somehow via Chrome DevTools Protocol? Like it is possible in Nightwatch.js/Selenium: <code>browser.frame(frameIndex)</code></p>