playwright テストを使用してタブを切り替えようとしていますが、windows 要素を制御していません。playwright の selenium driver.switchto().window() に似たメソッドはありますか?
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch({ headless: false, args: ['--start-maximized'] });
const context = await browser.newContext({ viewport: null });
context.on("page", async newPage => {
console.log("***newPage***", 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(),"Sign In")]')
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()="launch-app-from-dashboard"])[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()="OK"]')
await page.click('//bdi[text()="OK"]')
})()