TestCafe is a cross-browser E2E testing framework that requires no WebDriver or browser plugins. Integrate KnoxProxy to validate geo-restricted content, test localized UIs from multiple countries, and verify CDN behavior across regions.
Add TestCafe globally or as a project dependency.
npm install --save-dev testcafeTestCafe has a built-in --proxy CLI option for routing browser traffic through a proxy.
npx testcafe chrome tests/ --proxy gw.knoxproxy.com:7000Use the --proxy flag with credentials embedded in the URL or set via environment.
npx testcafe chrome tests/ \
--proxy USER:PASS@gw.knoxproxy.com:7000Use --proxy-bypass to skip the proxy for local or internal domains.
npx testcafe chrome tests/ \
--proxy USER:PASS@gw.knoxproxy.com:7000 \
--proxy-bypass localhost,*.internal.devAppend the country code to the proxy username for geo-targeted tests.
npx testcafe chrome tests/ \
--proxy USER-country-fr:PASS@gw.knoxproxy.com:7000Set the proxy in a .testcaferc.cjs config file for CI integration.
module.exports = {
proxy: 'USER:PASS@gw.knoxproxy.com:7000',
proxyBypass: ['localhost'],
browsers: ['chrome:headless'],
src: ['tests/'],
};import { Selector } from 'testcafe';
fixture('Geo-targeted tests via KnoxProxy')
.page('https://httpbin.org/ip');
test('Should exit from proxy IP', async (t) => {
const body = Selector('pre');
await t.expect(body.exists).ok();
const text = await body.textContent;
console.log('Exit IP:', text);
});
test('Should load localized homepage', async (t) => {
await t.navigateTo('https://example.com');
const title = Selector('title');
await t.expect(title.exists).ok();
});TestCafe creates a fresh browser instance per test run. Each connection gets a new IP by default. For sticky sessions, use USER-session-{id} in the proxy username.
| Problem | Fix |
|---|---|
| Error: Unable to establish a proxy tunnel | Verify the USER:PASS@gw.knoxproxy.com:7000 format. Ensure port 7000 is not blocked by firewall. |
| Test timeout on page load | Increase the assertionTimeout and pageLoadTimeout in .testcaferc.cjs or via CLI flags --assertion-timeout 20000. |
USER-country-de-city-berlin-session-profile07Order matters -- geo flags before the session flag. The session name is free text; use the profile ID so the mapping is self-documenting. Password stays as issued; no flags belong there. HTTP on :7000, SOCKS5 on :7001, same credentials.
Yes, pass credentials directly in the --proxy CLI flag as USER:PASS@gw.knoxproxy.com:7000, the same format used for country targeting. You can also set the proxy field once in the .testcaferc.cjs config file for CI runs, so every test command reuses the same authenticated KnoxProxy connection automatically.
Run separate TestCafe commands, each with a different --proxy country username such as USER-country-fr or USER-country-jp, rather than a single command covering multiple geos at once. Alternatively, write a test runner script that switches the proxy credentials between fixture groups, so one CI job still exercises several countries sequentially.
The --proxy flag only routes traffic from the browser instance TestCafe controls, not requests made directly in Node.js test code. For API calls issued from before/after hooks or helper functions outside the browser, set HTTP_PROXY and HTTPS_PROXY environment variables separately so those requests also route through KnoxProxy.
All TestCafe-supported browsers respect the --proxy flag equally, including Chrome, Firefox, Edge, and Safari, since TestCafe injects the proxy configuration at its own network layer instead of relying on native browser proxy settings. This means you get consistent KnoxProxy routing regardless of which browser a test targets.
Rotating residential proxies -- 5 minutes setup, instant activation, 14-day money-back guarantee.