title: Puppeteer - How to interact with new window or force new window into same instance
body: <p>I am using Puppeteer for testing in non-headless mode with Chromium. I have a part of a test where it clicks on a node on a webpage and that opens a new window. I am unable to interact with that new window. I have tried <code>browser.pages()</code>, unfortunately it only yields interaction with the pre-existing tabs in the original Chromium instance, not the new window.</p>
  
  <p>example:</p>
  
  <pre><code>let pages = await browser.pages();
  let newWindow = pages[pages.length - 1];
  // try to find element on newWindow - fails
  // last element in pages is still window that click was made in to open new window
  </code></pre>
  
  <p>I have found <code>event: 'targetcreated'</code> in the Puppeteer API but have been unable to figure out how to use it to access a new window.</p>
  
  <p>I have also tried using <code>browser.targets()</code> to get the new instance but have not been successful.</p>
  
  <p>I would like to know either how to interact with a new window instance or how to force all new windows to open in the same instance so they can be interacted with via <code>browser.pages()</code>.</p>
  
  <p>I don't believe this is a duplicate of the linked question about a similar subject of detecting when a new tab is opened as I am not just trying to detect when a new tab is opened but also to access the new tab/window within the test that opened the new tab/window.</p>