Integration · Test framework · via REST API

Fresh, masked test data for Selenium tests

Selenium's own docs say not to use the browser to set up test data, and to use APIs instead. A session fixture can call the Synthesized REST API, refresh the test database with masked or synthetic data, and only then let the browser tests start.

Selenium and Synthesized at a glance

There is no Selenium plugin; this pattern uses the documented REST API.

Where the call goesYour test framework's once-per-run setup: a session-scoped pytest fixture, JUnit @BeforeAll, TestNG @BeforeSuite or NUnit [OneTimeSetUp].
How it connectsStart the workflow with POST /external/api/v1/workflow/{id}/run, then poll GET /workflow-run/{id} until it is final.
ConfigurationGOVERNOR_URL, WORKFLOW_ID and GOVERNOR_ACCESS_KEY as environment variables.
GridRuns on the machine that starts the suite, not on Grid nodes.
StatusWorks through the REST API. Selenium isn't named in the Synthesized docs; the API calls are.

Set it up

1. Build the workflow in Governor

Create the masking, subsetting or generation workflow that fills your test database, and run it once by hand.

2. Provide the settings

Set GOVERNOR_URL, WORKFLOW_ID and GOVERNOR_ACCESS_KEY in the environment, from your CI secret store.

3. Add the fixture

Add the session fixture below to conftest.py, or the equivalent setup method in your framework.

4. Run the suite

The fixture refreshes the data once, before the first test. If the run fails, the suite stops.

Example pytest fixture

Python with requests; the same three calls work from Java, C# or JavaScript.

conftest.py

import os
import time
 
import pytest
import requests
 
API = f"{os.environ['GOVERNOR_URL']}/external/api/v1"
HEADERS = {"X-Access-Key": os.environ["GOVERNOR_ACCESS_KEY"]}
 
 
@pytest.fixture(scope="session", autouse=True)
def synthesized_test_data():
"""Refresh the test database once, before any Selenium test runs."""
start = requests.post(f"{API}/workflow/{os.environ['WORKFLOW_ID']}/run", headers=HEADERS, timeout=30)
start.raise_for_status()
run_id = start.json()["workflow_run_id"]
deadline = time.monotonic() + 30 * 60
while time.monotonic() < deadline:
res = requests.get(f"{API}/workflow-run/{run_id}", headers=HEADERS, timeout=30)
res.raise_for_status()
run = res.json()
if run["workflow_run_status"] == "COMPLETED":
return
if run["workflow_run_status"] in ("FAILED", "STOPPED"):
pytest.exit(f"Test data refresh failed: {run['error_message']}", returncode=1)
time.sleep(10)
pytest.exit("Test data refresh timed out", returncode=1)

Things to know

Use a dedicated key

An access key carries the permissions of the Governor user who generated it. Create a user that can reach only the workflows this pipeline runs, generate the key as that user, and give it a short expiry: keys are chosen from 1 hour to a year, and the docs say they can't yet be revoked.

One output database per environment

Two runs can't write to the same output database at the same time. If parallel pipelines or branches need data, give each environment its own workflow or output database.

Where the data goes

Workers read the source, mask, subset or generate, and write the target. Database contents stay with the workers and aren't sent to Governor, which, like the pipeline, only sees run status, logs and configuration. Run Synthesized on-premises, including air-gapped, and the data never leaves your environment; it is also available as SaaS.

Questions about Selenium and Synthesized

Is there a Selenium plugin?

No. Your test framework's setup code calls the Synthesized REST API, so it works with any Selenium setup that can reach your Governor over HTTPS. You need an HTTP client (the example uses Python's requests), the Governor URL, a workflow ID and an access key.

Why not create the test data with Selenium?

Selenium's own guidance is that it should not be used to prepare a test case: create data through APIs, and keep the browser for the behaviour under test.

Which languages does this work in?

Any. The calls are plain HTTPS, so the same pattern fits a pytest fixture, JUnit @BeforeAll, TestNG @BeforeSuite or NUnit [OneTimeSetUp].

Does it work with Selenium Grid?

Yes. The refresh runs once on the machine that starts the suite; Grid nodes only run the browsers.

Should I use runsync instead of polling?

runsync is simpler, because one call waits for the run to finish. Polling is safer for long runs, because it doesn't depend on one HTTP request staying open.

Try it on one suite

Bring one Selenium suite that depends on production-like data, and see Synthesized prepare it before the run.

Updated November 2026

All product names, including Selenium, are trademarks of their respective owners.