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 in the --proxy flag as USER:PASS@host:port, or set them in the .testcaferc.cjs config file.
Run separate TestCafe commands with different --proxy country usernames, or use a test runner script that switches proxy credentials between fixture groups.
The --proxy flag routes browser traffic through the proxy. For API calls in Node.js test hooks, set HTTP_PROXY environment variables separately.
All TestCafe-supported browsers (Chrome, Firefox, Edge, Safari) respect the --proxy flag.
Free trial on rotating residential -- 5 minutes setup, no credit card.