Test GDPR and CCPA Consent Banners with Proxies
November 17, 2026
Consent banners are one of the few pieces of UI that legitimately change by country, which is exactly why they ship broken. Someone checks the banner once from the office, clicks Reject all, and moves on. A reviewer in another region then sees a different CMP, different wording, or no banner at all, with marketing tags firing regardless.
Why your office IP proves almost nothing
Most consent management platforms (CMPs) decide per request. They read the visitor's IP country, often Accept-Language and the timezone, pick a policy, and cache that decision in a first-party cookie or localStorage entry for months. Test from headquarters or a CI runner and you exercise one branch: the country your egress IP geolocates to. Every other branch is untested production code.
Three signals feed that decision and they can disagree. Real visitors produce every combination, so your matrix should include the ones that matter rather than only the happy path.
Build the matrix before you write code
Write down, per country, what correct looks like. Skipping this step is how flaky region tests get born.
- Germany, France, Netherlands: banner on first visit, TCF consent string attached to ad calls
- Brazil: banner with LGPD wording
- United States: notice-style banner or footer link, plus a us_privacy value on ad calls
- Japan, Singapore, Australia: often no banner at all. That nothing-happens case is the assertion teams forget to write
Two limits to design around. A country-level exit IP cannot separate California from Texas, so assert what is actually observable (a US-style notice exists, us_privacy is set) and cover state-level rules from a connection inside that state. And keep the matrix small: five countries you can explain beat twenty you cannot.
Step 1: Give every country its own proxy
On the Business plan you choose the country of the IP among the countries in stock, so the clean setup is one RoProxy proxy per country in the matrix, each with its own username and password, all reaching the same gateway host on an HTTP port.
{
"DE": "http://USERNAME:PASSWORD@GATEWAY_HOST:HTTP_PORT",
"US": "http://USERNAME:PASSWORD@GATEWAY_HOST:HTTP_PORT",
"BR": "http://USERNAME:PASSWORD@GATEWAY_HOST:HTTP_PORT"
}
HTTPS uses that same port: the client opens a CONNECT tunnel through it, so there is no separate TLS configuration to maintain. If you prefer SOCKS5, Pro and Business plans expose a SOCKS5 port on the same gateway host - socks5h://USERNAME:PASSWORD@GATEWAY_HOST:SOCKS5_PORT - which also resolves DNS remotely instead of locally. The requests library needs the well-known PySocks extra for that scheme.
Confirm the exit IP before you trust a single assertion:
import json
import requests
with open("proxies.json") as fh:
MATRIX = json.load(fh)
LOCALES = {"DE": "de-DE", "US": "en-US", "BR": "pt-BR"}
def client(country):
s = requests.Session()
s.proxies = {"http": MATRIX[country], "https": MATRIX[country]}
s.headers["Accept-Language"] = LOCALES[country]
return s
print(client("DE").get("https://api.ipify.org?format=json", timeout=20).json())
Then pin rotation for the duration of the run. Consent tests are region assertions, and an IP that changes mid-suite can move a request to another country and fail a test that was correct. Use sticky mode, which holds the IP until it is rotated or fails, or set the timed interval longer than the whole suite. The Free plan changes IP on a fixed schedule and cannot be rotated by hand, so keep it out of region-locked checks.
Step 2: Smoke-test the banner in raw HTML
Fetch the page with a clean session and look for the CMP container.
from bs4 import BeautifulSoup
MARKERS = {
"onetrust": "#onetrust-banner-sdk",
"cookiebot": "#CybotCookiebotDialog",
"cc-window": ".cc-window",
"didomi": "#didomi-host",
}
def detect(html):
soup = BeautifulSoup(html, "html.parser")
return [name for name, sel in MARKERS.items() if soup.select_one(sel)]
This catches a deploy that dropped the CMP script entirely, and it costs milliseconds per country. It is not proof: many CMPs inject the banner client-side, so a missing marker only means open a browser. Verify the selectors against your own CMP, since vendors rename them.
Step 3: Click through in a browser and watch what fires
The interesting assertion is not that the banner appears. It is what stops appearing after Reject all.
from playwright.sync_api import sync_playwright
AD_HOSTS = ("doubleclick.net", "googlesyndication.com", "/tr?")
def split_proxy(url):
creds, hostport = url.split("://", 1)[1].split("@", 1)
user, pwd = creds.split(":", 1)
return {"server": "http://" + hostport, "username": user, "password": pwd}
def click_reject(page):
for sel in ("#onetrust-reject-all-handler",
"#CybotCookiebotDialogBodyButtonDecline",
".cc-reject"):
btn = page.query_selector(sel)
if btn:
btn.click()
return
raise AssertionError("no reject control found")
def run_country(country, decide, url):
ads = []
with sync_playwright() as p:
browser = p.chromium.launch(headless=True, proxy=split_proxy(MATRIX[country]))
ctx = browser.new_context(locale=LOCALES[country])
page = ctx.new_page()
page.on("request", lambda r: ads.append(r.url)
if any(h in r.url for h in AD_HOSTS) else None)
page.goto(url, wait_until="domcontentloaded")
page.wait_for_selector(BANNER[country], timeout=10_000)
decide(page)
page.wait_for_timeout(3_000)
stored = page.evaluate("Object.keys(localStorage)")
page.reload(wait_until="domcontentloaded")
page.wait_for_timeout(2_000)
returned = page.query_selector(BANNER[country]) is not None
browser.close()
return {"ads": ads, "storage": stored, "banner_returned": returned}
Each call gets a fresh context, so no cookie or localStorage from a previous country leaks in. After the click, inspect the stored keys (euconsent-v2, OptanonConsent, cc_cookie, didomi_token) and fail when the storage contradicts the UI: a banner that was dismissed but stored nothing means the choice will not survive a reload for real visitors either.
Step 4: Assert the contract, not the pixels
- First visit in a clean context shows the expected UI for that country.
- Reject all produces zero requests to marketing hosts.
- Accept all produces marketing requests carrying gdpr_consent (EU) or us_privacy (US).
- Reload does not resurface the banner, and the consent key exists.
- The CMP's own endpoint loads through the proxy. A blocked CMP fails open or closed depending on its configuration, and both are worth knowing before launch.
Screenshot the banner too, but keep images out of the pass/fail decision. Copy changes weekly; tag behavior is the actual contract with your legal and marketing teams.
Step 5: Run it in CI
import pytest
@pytest.mark.parametrize("country", sorted(MATRIX))
def test_consent_contract(country):
result = run_country(country, click_reject, URL)
assert result["ads"] == [], f"{country}: marketing tags fired after Reject all"
assert not result["banner_returned"], f"{country}: banner returned after reload"
Load credentials from your secret store or CI variables, never from a file committed to the repository, and print the exit IP in failure output so a geolocation mismatch is obvious in the log rather than showing up as a mysterious selector timeout.
False failures to rule out first
- Exit IP not in the expected country. Assert it, do not assume it.
- Warm profile. A reused persistent context keeps the previous run's consent decision.
- Accept-Language contradicting the IP. Some CMPs weight the header heavily; test aligned and conflicting pairs deliberately.
- Headless. A few CMPs serve a reduced experience to headless browsers, so compare one run in headed mode.
- Cached HTML at the CDN edge. Add a cache-busting query parameter when a markup change is not landing.
- Async CMP load. Wait for the selector, not for network idle.
Conclusion
Consent coverage is a matrix problem, so treat it like one: a written per-country expectation, a clean browser context per run, and assertions on tag behavior rather than on appearance. RoProxy fits that shape, since each proxy has its own username and password through a gateway host on an HTTP port, with SOCKS5 on Pro and Business, sticky or timed rotation you set per proxy, and country selection among the countries in stock on Business. New accounts get free proxies, which is enough to prove the harness works before you expand the matrix.