Automated testing
Useful when the thing under test behaves differently for traffic it thinks is automated:
- Sites that serve a different page to bots
- Your own bot detection, checked against something that actually evades it
- Geography-dependent behavior, through a proxy with a matching timezone
- Layout at screen sizes real devices have
import httpxfrom playwright.sync_api import sync_playwright
KEY = "rb_live_YOUR_KEY"
resp = httpx.get( "https://browser.rayobyte.com/connect", params={ "os": "windows", "headless": "true", "proxy": PROXY, "screen_width_min": 1280, "screen_height_min": 720, }, headers={"x-api-key": KEY}, timeout=120,)if resp.status_code != 200: raise SystemExit(f"{resp.status_code}: {resp.text}")cdp_url = resp.text.strip()session_id = resp.headers["x-session-id"]
try: with sync_playwright() as p: browser = p.chromium.connect_over_cdp(cdp_url) context = browser.contexts[0] page = context.pages[0] if context.pages else context.new_page() page.goto("https://quotes.toscrape.com/login")
assert page.title() == "Quotes to Scrape" assert page.locator("input[type=submit]").is_visible()finally: httpx.post( "https://browser.rayobyte.com/api/browser/close", json={"browserId": session_id}, headers={"x-api-key": KEY}, timeout=30, )Fingerprints differ between runs
Section titled “Fingerprints differ between runs”Each session draws a different device profile, so values such as the screen
size and the font list are not the same twice. A test that asserts on navigator.userAgent or
on a pixel-exact screenshot fails on the second run for reasons that have nothing
to do with your application.
Pin what you need: screen_width_min, screen_height_min, os and the browser
version parameters all constrain the profile. For a fully fixed device, email
[email protected].
CI concurrency
Section titled “CI concurrency”5 concurrent browsers is the account limit, not a per-pipeline one. Test suites
running in parallel across branches share it, and the sixth job gets
429 Concurrent browser limit reached rather than a queue. Cap your parallelism below 5, or
email [email protected].
Was this page helpful?
Thanks — that helps us fix it.