test("page.waitForFunction_sample", async ({ page }) => { await page.goto("https://www.lambdatest.com/selenium-playground/simple-form-demo") // テキストボックス入力を監視する関数を定義 const watchDog = page.waitForFunction(() => { return document.querySelector("input#user-message").value === "hello world!" }) // 2秒後に "hello world!" を入力 setTimeout(async () => { await page.locator("input#user-message").fill("hello world!") }, 2000) // 監視を実地、入力を確認できたら終了 console.log("result:" + (await watchDog)) console.log("exit!") })