# Running Safari Tests Across Multiple macOS Versions

Canonical: https://figment.so/blog/mac-multi-os-version-safari-rental

Run the same Safari WebDriver fixture on one Mac per macOS version and record exact macOS and Safari builds. A Figment plan runs one pinned macOS version, shown before purchase, so a two-version matrix needs two machines.

**Run the same fixture with Apple's Safari WebDriver on one Mac per macOS version you need, and record the exact macOS and Safari builds in each report.** A browser name in a CI job tells you less than the versions in the test report. Testing several macOS versions needs one Mac or VM for each version, so decide first which version pairs matter to your users. [Apple's Safari WebDriver documentation](https://developer.apple.com/documentation/webkit/about-webdriver-for-safari)

## Which variable should I compare?

Change one variable at a time: the Safari build, the macOS version, or the customer setup you still support.

| Question | Test setup |
|---|---|
| Did a newer Safari release change a feature? | Compare the older and newer Safari builds. Keep macOS and hardware the same if both builds are available in your test environments. |
| Does the site behave differently on Ventura and Sequoia? | Test the same Safari release on both OS versions where possible. Record the exact Safari build on each host. |
| Can we drop support for an older customer setup? | Reproduce the Safari and macOS pairs that customers actually use. Run the release checks on both and compare failures by test name. |

Safari 18 was available on Ventura, Sonoma and Sequoia, so a Mac running Ventura can have Safari 18. Use an older Safari build only if it represents a version you still support. For example, test `document.startViewTransition` and unprefixed `backdrop-filter` when comparing Safari 16 and 18. If an older browser lacks a feature, the application test should verify the fallback. [WebKit's Safari 18 release notes](https://webkit.org/blog/15865/webkit-features-in-safari-18-0/)

## Which hardware supports which macOS version?

Check Apple's compatibility list for each OS you test. Apple lists the 2020 M1 Mac mini, 2023 Mac mini and 2018 Mac mini as compatible with Ventura. [Apple's Ventura compatibility list](https://support.apple.com/en-us/102861)

Figment shows the pinned macOS version for each plan before purchase, and a plan runs one macOS version at a time. The Intel Mac VM runs macOS Sequoia. For the Apple silicon plans, check the version shown before purchase. We do not offer a choice of macOS versions beyond that, so if a test needs Ventura or another specific older release, use a Mac you control or a host that lists that version, and get the model and macOS version in writing.

## How do I run one fixture in system Safari?

Enable Safari's remote automation once on each test host with `safaridriver --enable`, then run the test under the account that will own the Safari session. Use the same Selenium version, fixture revision, viewport, locale and feature settings on every host, and store each report as a build artifact. Playwright's bundled WebKit can run an early smoke check, but use system Safari for your release result. [Apple's instructions for enabling Safari WebDriver](https://developer.apple.com/documentation/webkit/testing-with-webdriver-in-safari) · [Playwright's browser documentation](https://playwright.dev/docs/browsers)

This example probes two WebKit features. It needs a test page with an element whose ID is `safari-matrix-ready`; add the marker after the fixture loads and set its `data-revision` attribute to the fixture revision. Set `EXPECTED_SAFARI` and `EXPECTED_MACOS` to the exact values you intend to compare, and `FIXTURE_REV` to the version deployed at `TEST_URL`.

```python
import json
import os
import subprocess
from pathlib import Path

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as conditions
from selenium.webdriver.support.ui import WebDriverWait

driver = webdriver.Safari()
try:
    os_version = subprocess.check_output(
        ["sw_vers", "-productVersion"], text=True
    ).strip()
    os_build = subprocess.check_output(
        ["sw_vers", "-buildVersion"], text=True
    ).strip()
    safari = driver.capabilities["browserVersion"]
    safari_build = subprocess.check_output(
        ["defaults", "read", "/Applications/Safari.app/Contents/Info", "CFBundleVersion"],
        text=True,
    ).strip()
    if safari != os.environ["EXPECTED_SAFARI"]:
        raise SystemExit(f"Expected Safari {os.environ['EXPECTED_SAFARI']}, got {safari}")
    if os_version != os.environ["EXPECTED_MACOS"]:
        raise SystemExit(f"Expected macOS {os.environ['EXPECTED_MACOS']}, got {os_version}")

    driver.get(os.environ["TEST_URL"])
    marker = WebDriverWait(driver, 10).until(
        conditions.presence_of_element_located((By.ID, "safari-matrix-ready"))
    )
    if marker.get_attribute("data-revision") != os.environ["FIXTURE_REV"]:
        raise SystemExit("The expected fixture revision did not load")
    features = driver.execute_script("""
        return {
          viewTransitions: typeof document.startViewTransition === "function",
          unprefixedBackdropFilter: CSS.supports("backdrop-filter", "blur(2px)")
        };
    """)
    if not features or not all(type(value) is bool for value in features.values()):
        raise SystemExit("Feature probe produced invalid evidence")
    report = {
        "fixture": os.environ["FIXTURE_REV"],
        "macOS": os_version,
        "macOSBuild": os_build,
        "safari": safari,
        "safariBuild": safari_build,
        "features": features,
    }
    Path(os.environ["REPORT_PATH"]).write_text(json.dumps(report, indent=2) + "\n")
finally:
    driver.quit()
```

Use a new report path each run so a previous result cannot satisfy a failed job. Keep WebDriver local to the test host, and let each runner pull CI work from your CI service.

## How do I decide what to fix before release?

Require two nonempty reports with the same fixture revision and the same set of checks, then list the differences. Save this example as `compare-safari.py` and run it on the two JSON files. The absence of a feature can be expected, so use application tests to decide whether the release passes.

```python
import json
import sys
from pathlib import Path

if len(sys.argv) != 3:
    raise SystemExit("Usage: compare-safari.py older.json newer.json")

old, new = (json.loads(Path(path).read_text()) for path in sys.argv[1:])
if not old["fixture"] or old["fixture"] != new["fixture"]:
    raise SystemExit("Expected reports from the same fixture revision")
older = old["features"]
newer = new["features"]
if not older or older.keys() != newer.keys():
    raise SystemExit("Missing or inconsistent feature checks")
if any(type(value) is not bool for features in (older, newer) for value in features.values()):
    raise SystemExit("Invalid feature result")

for name in sorted(older):
    if older[name] != newer[name]:
        print(f"{name}: {older[name]} -> {newer[name]}")
```

Group each difference into an expected browser capability gap, a missing application fallback or an unexplained failure. For an expected gap, add a test of the fallback. For an unexplained failure, repeat the test on the same host before attributing it to Safari or macOS.

If your own usage data shows customers still depend on the older browser, keep its release checks until your published support policy changes. Archive the reports and the exact browser builds with the release decision.

## How many Macs does a two-version Safari matrix need?

One Figment Mac covers one macOS and Safari pair, so a two-version matrix needs two machines. The Intel Mac VM ($25 a month, $2 a day) runs macOS Sequoia with the Safari that Sequoia ships and fits a current-Safari run. The Apple Silicon Mac VM ($39 a month, $6 a day) fits a second pair when the macOS version shown before purchase matches the version you need. For several Macs at once, enterprise needs are quoted on a call. See the [Mac hosting plans](/mac-hosting).
