title: switch tabs in playwright test
body: <p>I'm trying to switch between tabs using playwright tests
  but it's not taking control of windows element.
  Do we have any method similar to selenium driver.switchto().window() in playwright?</p>
  <pre><code>const { chromium } = require('playwright');
  (async () =&gt; {
      const browser = await chromium.launch({ headless: false, args: ['--start-maximized'] });
      const context = await browser.newContext({ viewport: null });
      context.on(&quot;page&quot;, async newPage =&gt; {
          console.log(&quot;***newPage***&quot;, await newPage.title())
      })
      const page = await context.newPage()
      const navigationPromise = page.waitForNavigation()
  
      // dummy url
      await page.goto('https://www.myapp.com/')
      await navigationPromise
  
      // User login
      await page.waitForSelector('#username-in')
      await page.fill('#username-in', 'username')
      await page.fill('#password-in', 'password')
      await page.click('//button[contains(text(),&quot;Sign In&quot;)]')
      await navigationPromise
  
      // User lands in application home page and clicks on link in dashboard 
      // link will open another application in new tab 
      await page.click('(//span[text()=&quot;launch-app-from-dashboard&quot;])[2]')
  
      await navigationPromise
      await page.context()
      // Waiting for element to appear in new tab and click on ok button
      await page.waitForTimeout(6000)
      await page.waitForSelector('//bdi[text()=&quot;OK&quot;]')
      await page.click('//bdi[text()=&quot;OK&quot;]')
  
  })()
  </code></pre>