Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e/tests/visual.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
15 changes: 11 additions & 4 deletions frontend/src/examples/javascript/intercept-modify-requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -17,22 +23,23 @@ 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.
route.fulfill({
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: ''
})
})

Expand All @@ -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'
Expand Down
Loading