From d871c94e9c2228f7ab7b11754db28f701b8e5781 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 4 Sep 2026 15:29:28 +0000 Subject: [PATCH] Fix example 7 e2e hang caused by production Turnstile The modifying-network-requests example drives live try.playwright.tech. After Turnstile shipped, automated browsers get error 600010, Run never POSTs /service/control/run, and CI waited two minutes for a duration banner that never appeared. Skip the bot check via the existing __TRY_PLAYWRIGHT_TURNSTILE__ flag, and give the execution-timeout assertion more slack on Firefox. Co-authored-by: Max Schmitt --- e2e/tests/visual.spec.ts | 2 +- .../javascript/intercept-modify-requests.js | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/e2e/tests/visual.spec.ts b/e2e/tests/visual.spec.ts index dfc4cde8..df71770d 100644 --- a/e2e/tests/visual.spec.ts +++ b/e2e/tests/visual.spec.ts @@ -148,7 +148,7 @@ test.describe("should handle platform core related features", () => { await page.getByRole('button', { name: 'Run'}).click(); await expect(page.getByText("Execution timeout!")).toBeVisible({ - timeout: 70 * 1000, + timeout: 90 * 1000, }); }) test("should handle uncaughtException correctly", async ({ page }) => { diff --git a/frontend/src/examples/javascript/intercept-modify-requests.js b/frontend/src/examples/javascript/intercept-modify-requests.js index 04c86b70..353ea2f0 100644 --- a/frontend/src/examples/javascript/intercept-modify-requests.js +++ b/frontend/src/examples/javascript/intercept-modify-requests.js @@ -9,6 +9,12 @@ const IMAGE_URL = 'https://placehold.co/300x70?text=Yey+Playwright!'; // Cloudflare does block us otherwise userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36' }); + // Production enables Cloudflare Turnstile for real users. Automated browsers + // fail that check (Turnstile error 600010) and never POST /service/control/run, + // so this intercept demo would hang. The playground honors this flag. + await context.addInitScript(() => { + window['__TRY_PLAYWRIGHT_TURNSTILE__'] = 'noop'; + }); const page = await context.newPage(); // Open the exact same page on which we are right now await page.goto('https://try.playwright.tech'); @@ -17,7 +23,7 @@ const IMAGE_URL = 'https://placehold.co/300x70?text=Yey+Playwright!'; // service. We respond for all the backend calls which are made by pressing the // 'Run' button a hard-coded response which will lead to a blue banner with the // text Playwright. - await page.route('https://try.playwright.tech/service/control/run', (route) => { + await page.route('**/service/control/run', (route) => { // Here you can either modify the response by using 'route.fulfill()' or // just continue as normal by using 'route.continue()'. Try to remove // the entire statement and replace it with the other one in the bottom. @@ -25,14 +31,15 @@ const IMAGE_URL = 'https://placehold.co/300x70?text=Yey+Playwright!'; status: 200, contentType: 'application/json', body: JSON.stringify({ + success: true, version: 'We are intercepting Requests', duration: 12346789, files: [{ - filename: 'banner.png', + fileName: 'banner.png', publicURL: IMAGE_URL, extension: '.png' }], - logs: [] + output: '' }) }) @@ -45,7 +52,7 @@ const IMAGE_URL = 'https://placehold.co/300x70?text=Yey+Playwright!'; await Promise.all([ // Wait until the image is fully loaded page.waitForResponse(response => ( - response.url().endsWith(IMAGE_URL) || response.url().endsWith('.png') + response.url().includes('placehold.co') || response.url().endsWith('.png') )), page.getByRole('button', { name: 'Run'