SPB Git

Repository Public License

shots.py 1.8 KB 37 lines python

1#!/usr/bin/env python32# ORIX Secure3# File: Scripts/shots.py4# Description: Collects the named screenshots of a UI test run (build/shots/<sim>/manifest.json) into build/shots/<sim>/named/<name>.png5#              and, with --hierarchy <test>, prints the accessibility hierarchy captured when that test failed.6#7# Author: Simon-Pierre Boucher8# Contact: contact@spboucher.ai9import json, os, shutil, sys1011sim = sys.argv[1] if len(sys.argv) > 1 else "ORIXSecure_iPhone"12root = os.path.join(os.path.dirname(__file__), "..", "build", "shots", sim)13manifest = json.load(open(os.path.join(root, "manifest.json")))14if "--hierarchy" in sys.argv:15    wanted = sys.argv[sys.argv.index("--hierarchy") + 1]16    for test in manifest:17        if wanted in test.get("testIdentifier", ""):18            for a in test.get("attachments", []):19                if a.get("suggestedHumanReadableName", "").startswith("App UI hierarchy"):20                    print(open(os.path.join(root, a["exportedFileName"])).read())21                    sys.exit(0)22    sys.exit("no hierarchy for " + wanted)23named = os.path.join(root, "named")24shutil.rmtree(named, ignore_errors=True)25os.makedirs(named)26for test in manifest:27    for a in test.get("attachments", []):28        name = a.get("suggestedHumanReadableName", "")29        if name.endswith(".png") and not name.startswith(("UI Snapshot", "Screenshot")):30            target = os.path.join(named, name.split("_0_")[0] + ".png")31            shutil.copy(os.path.join(root, a["exportedFileName"]), target)32            if "iPad" in sim:33                # XCUIScreen captures the iPad framebuffer in portrait while the tests run in landscape.34                from PIL import Image35                Image.open(target).rotate(90, expand=True).save(target)36print("\n".join(sorted(os.listdir(named))))37
Files main
Menu

Theme