How to Intercept Playwright Traffic with Fluxzy
Intercepting traffic from Playwright tests lets you debug API calls, verify request payloads, analyze performance, and troubleshoot authentication issues. This guide shows you how to configure Playwright to route traffic through Fluxzy.
What You'll Learn
- Configure Playwright to use Fluxzy as a proxy
- Handle HTTPS certificates properly
- Set up interception in Python, Node.js, and .NET
- Debug and inspect captured traffic
Prerequisites:
- Fluxzy Desktop or CLI installed (download here)
- Playwright installed in your project
Two Requirements for Interception
To intercept HTTPS traffic from Playwright, you must satisfy two conditions:
- Proxy Configuration - Tell Playwright to route traffic through Fluxzy (default:
http://127.0.0.1:44344) - Certificate Handling - Set
ignoreHTTPSErrors: trueon the browser context
Start Fluxzy
Before running your tests, start Fluxzy to listen for connections.
Using Fluxzy Desktop:
- Open Fluxzy Desktop
- Click Start Capture (or press F5)
- Default proxy address:
127.0.0.1:44344
Using Fluxzy CLI:
fluxzy start -l 127.0.0.1:44344
Configure Playwright
Playwright must be configured to route traffic through Fluxzy's proxy and to accept Fluxzy's certificate. The ignoreHTTPSErrors option tells the browser to skip certificate validation, allowing Fluxzy to intercept HTTPS traffic.
Node.js (TypeScript/JavaScript)
import { chromium } from 'playwright';
const browser = await chromium.launch({
proxy: {
server: 'http://127.0.0.1:44344'
}
});
const context = await browser.newContext({
ignoreHTTPSErrors: true
});
const page = await context.newPage();
await page.goto('https://example.com');
// Your test code here
await browser.close();
With Playwright Test:
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
proxy: {
server: 'http://127.0.0.1:44344'
},
ignoreHTTPSErrors: true
}
});
Python
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch(
proxy={
"server": "http://127.0.0.1:44344"
}
)
context = browser.new_context(
ignore_https_errors=True
)
page = context.new_page()
page.goto("https://example.com")
# Your test code here
browser.close()
With pytest-playwright:
# conftest.py
import pytest
@pytest.fixture(scope="session")
def browser_context_args(browser_context_args):
return {
**browser_context_args,
"ignore_https_errors": True
}
@pytest.fixture(scope="session")
def browser_type_launch_args(browser_type_launch_args):
return {
**browser_type_launch_args,
"proxy": {
"server": "http://127.0.0.1:44344"
}
}
.NET (C#)
using Microsoft.Playwright;
var playwright = await Playwright.CreateAsync();
var browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions
{
Proxy = new Proxy
{
Server = "http://127.0.0.1:44344"
}
});
var context = await browser.NewContextAsync(new BrowserNewContextOptions
{
IgnoreHTTPSErrors = true
});
var page = await context.NewPageAsync();
await page.GotoAsync("https://example.com");
// Your test code here
await browser.CloseAsync();
With NUnit/MSTest:
using Microsoft.Playwright;
using Microsoft.Playwright.NUnit;
public class InterceptedTests : PageTest
{
public override BrowserNewContextOptions ContextOptions()
{
return new BrowserNewContextOptions
{
IgnoreHTTPSErrors = true
};
}
[SetUp]
public async Task SetUp()
{
// Configure proxy at browser level
await Context.Browser.NewContextAsync(new BrowserNewContextOptions
{
IgnoreHTTPSErrors = true
});
}
}
Quick Reference
| Language | Proxy Setting | Certificate Handling |
|---|---|---|
| Node.js | proxy: { server: 'http://127.0.0.1:44344' } |
ignoreHTTPSErrors: true |
| Python | proxy={"server": "http://127.0.0.1:44344"} |
ignore_https_errors=True |
| .NET | Proxy = new Proxy { Server = "..." } |
IgnoreHTTPSErrors = true |
Troubleshooting
No Traffic in Fluxzy
Symptoms: Tests run but Fluxzy shows no exchanges.
Solutions:
- Verify Fluxzy is running and listening on the correct port
- Check proxy URL matches Fluxzy's listen address
- Ensure no firewall blocking localhost connections
- Try with
http://site first to verify basic connectivity
Certificate Errors Despite ignoreHTTPSErrors
Symptoms: SSL errors even with ignoreHTTPSErrors: true.
Solutions:
- Ensure
ignoreHTTPSErrorsis set on the context, not just browser - For Chromium, verify the option is passed correctly
- Some sites with certificate pinning may still fail - this is expected
Tests Timeout When Proxy Is Set
Symptoms: Tests hang or timeout after adding proxy configuration.
Solutions:
- Verify Fluxzy is running before tests start
- Check proxy server address is correct (no typos)
- Ensure Fluxzy isn't blocked by firewall or security software
- Try increasing test timeout temporarily to diagnose
Different Behavior in Headed vs Headless
Symptoms: Interception works in headed mode but not headless.
Solutions:
- Explicitly set proxy in launch options (not just environment variables)
- Some browser configurations differ - ensure consistent setup
- Check if any browser args are overriding proxy settings
Next Steps
- Core Concepts - Learn about filters, actions, and rules
- Rule File Syntax - Modify traffic with YAML rules
- Intercept Browser Traffic - Capture from regular browsers