🛠️ CLI & CI Integration Guide / CLI ve CI Entegrasyon Rehberi
💡 Select Language / Dil Seçin:
🇬🇧 English Guide
Every other guide on this site assumes a .NET project: reference a package, write C#, call SelfHealingResolver in-process. automation-sandbox-heal (AutomationSandbox.Cli) removes that requirement entirely. SelfHealingResolver.Resolve operates purely on the framework-agnostic UiElementInfo tree - no FlaUI, no Playwright .NET SDK, no Windows dependency - so the only real barrier between “any language, any CI” and this engine was packaging. This guide covers the whole story: the CLI itself, the JSON contract it reads and writes, the GitHub Action that wraps it, and a working capture example for a language other than C#.
Install
dotnet tool install -g AutomationSandbox.Cli --prerelease
--prerelease is required during the 0.x beta series; drop it once a stable 1.0 ships. This still requires the .NET runtime to be present on the machine - the tool itself is a real .NET executable, just one that needs no .NET project from its caller.
Basic Usage
automation-sandbox-heal --expected stale-element.json --tree live-tree.json --profile balanced
--expected- a singleUiElementInfoJSON object: the stale/broken locator’s last known snapshot.--tree- aUiElementInfoJSON tree: a freshly captured snapshot of the live application.--profile-balanced(default),conservative, oraggressive. See the healing-pipeline thresholds inAGENTS.mdfor what each trades off.
Prints a HealResult as JSON to stdout - the same explainable ScoreComponents breakdown, RunnerUpScore, and EvidenceCoverage every other API surface in this project exposes. Diagnostic logging goes to stderr, so stdout is always pure, parseable JSON. Exit code 0 means IsConfident (safe to accept Matched); 1 means not confident (do not auto-accept); 2 means an error occurred before a decision could be made (bad input, missing file) - never a raw stack trace.
The JSON Schema
Both JSON inputs, and the tool’s own output, follow a published JSON Schema. Point your editor or a validator at it for autocomplete and validation without reading any C# source:
{
"$schema": "https://mustafasercansak.github.io/automation-sandbox/schemas/ui-element-info.schema.json",
"ControlType": "Button"
}
Only the fields behind SimilarityScorer’s five weighted signals (ControlType, Name, AutomationId, BoundingRectangle, ParentControlType) are required; everything else is optional, matching the C# defaults the engine falls back to when a property is absent.
Using It in CI: the GitHub Action
A composite GitHub Action wraps the install, run, and JSON-parsing steps into one line:
- uses: mustafasercansak/automation-sandbox/.github/actions/heal@main
with:
expected: path/to/stale-element.json
tree: path/to/live-tree.json
profile: balanced
By default this step fails the job when the result is not confident - the same exit-code contract as the CLI itself, so a bare uses: line is already a working pass/fail gate. Add continue-on-error: true and read the is-confident/result outputs if you want to branch on the outcome instead of failing the build. An optional source input lets the action install from a private feed instead of nuget.org.
Capturing JSON from Any Language: Web (JS/Playwright)
The CLI is only useful once something produces its input. The repository ships a real, working reference for this: examples/js-playwright-capture, a Node.js + Playwright script that captures a web page’s DOM into the exact JSON shape above - mirroring the same role/accessible-name detection and ControlType/AutomationId mapping rules AutomationSandbox.WebDiscovery uses on the .NET side, so a tree captured in JS scores consistently with one captured in .NET. It’s deliberately minimal (regular DOM only - no Shadow DOM or iframe traversal), and ships with a bundled fixture so it runs with zero network dependency out of the box.
Capturing JSON from Any Language: Desktop (Python/pywinauto)
The same idea for Windows desktop applications: examples/python-pywinauto-capture, a Python script using pywinauto’s uia backend - the same underlying Windows UI Automation COM API FlaUI/UIA3 uses, so it produces genuinely equivalent data, not just a matching JSON shape. Unlike the JS example, this one could not be verified locally by the assistant that wrote it (no Windows/UI Automation access in that environment) - its real verification is a CI job (Desktop Capture (Python)) that builds this repository’s own WinForms demo app, launches it, captures its real UI tree, and confirms automation-sandbox-heal heals a synthetic stale locator built from that real data.
A minimal Python sketch, if your own tooling already produces a dict in the same shape:
import json, subprocess
result = subprocess.run(
["automation-sandbox-heal", "--expected", "expected.json", "--tree", "tree.json", "--profile", "balanced"],
capture_output=True, text=True,
)
heal_result = json.loads(result.stdout)
if result.returncode == 0:
print(f"Healed: use {heal_result['Matched']['AutomationId']} instead")
Scanning a Website for Typos: automation-sandbox-audit
A second tool, AutomationSandbox.SiteAudit (command automation-sandbox-audit), crawls a site from one URL and reports spelling mistakes, plus duplicated words and leftover placeholders. It needs no API key and sends no page text anywhere: spelling comes from Hunspell dictionaries, which handle inflected languages such as Turkish. It requires the .NET 8 runtime (or newer) and downloads Chromium for the crawl.
automation-sandbox-audit --url https://example.com --lang tr,en --allow-word Playwright --install-browser
--langlists dictionaries, primary language first (defaulten; regional variants such asen-GBwork, which matters becauseenis American spelling and flagsbehaviour). A word is accepted if any listed dictionary accepts it, which suits a Turkish page containing English terms; the trade-off is that a typo that happens to be a valid word in the other language is not reported. Turkish suffixes on foreign words (artifact'ları) are judged by the stem.--allow-word/--allow-filekeep brand and product names out of the report.- Dictionaries are downloaded once, from a pinned commit of
wooorm/dictionaries(nothing is bundled), into a per-user cache;--no-downloadforbids the download for offline use. - Exit code
0means no findings,1means findings (so a CI step can gate on it),2means the audit could not run (bad arguments, missing dictionary, start page unreachable). A JSON Lines log and an HTML report are written to--output-dir(overwritten on each run). - It judges single words only. Grammar and meaning are outside a dictionary’s reach, and brand names, jargon and code you did not allow-list will be reported as misspellings. Text is checked up to 10,000 characters per element. Expect many false positives on a developer-documentation site (the project’s own docs: 420 distinct flagged words across 31 pages, mostly terms such as
jsonandnuget; the English dictionary is small and lacks plurals likeintegrations); it suits marketing and content sites far better, and an allow list takes care of the rest. - Not published to nuget.org yet; until it is, pack it from the repository (
dotnet pack TestAutomation/SiteAuditCli). TheSite Audit CLICI job exercises the packed tool against a fixture site with the real Turkish and English dictionaries.
Running the typo audit on GitHub
A composite action wraps the install, run, summary and upload steps, so a scheduled workflow is one uses: line. It needs no API key, and no page text leaves the runner:
name: Typo audit
on:
schedule:
- cron: '0 6 * * 1'
workflow_dispatch:
jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: mustafasercansak/automation-sandbox/.github/actions/site-audit@main
with:
url: https://example.com
lang: tr,en
allow-words: |
Acme
Playwright
- It writes a findings table to the job summary and uploads the JSON and HTML report as an artifact (
upload-report: 'false'to skip,artifact-nameif the action runs twice in one job). - By default the job fails when anything is found. Set
fail-on-findings: 'false'to only report, and read theissue-countandexit-codeoutputs to branch on them. A run that could not execute (bad URL, missing dictionary) always fails, so a broken audit never looks like a clean site. - Because the tool is not on nuget.org yet, the action builds it from its own repository checkout, so the tool version is exactly the one at the ref you pin the action to. Pin a tag or commit SHA rather than
@mainfor a reproducible audit. That build adds about a minute. Once a version is published,version:installs it instead. - It audits the site as served, so it covers what a browser sees: run it after a deploy, or on a schedule against production. Chromium is installed by the tool; a self-hosted runner without the browser’s system libraries needs them installed first.
Why a CLI, Not Just the Library
AutomationSandbox.SelfHealing/AutomationSandbox.UiModel are the right choice for a .NET project that already captures its own UiElementInfo trees (via Discovery, WebDiscovery, or a hand-rolled adapter) and wants to call the resolver in-process. The CLI is for everything else: a non-.NET test suite, a shell script in a CI pipeline, or any tool that can produce a JSON tree but has no reason to take on a .NET dependency just to get a heal decision.
Known Limitations
- The published package currently only ships as a
--prereleaseversion during the0.xbeta series. - The JSON Schema is validated manually, not CI-enforced (this repo’s own tooling stays C#/PowerShell-only) - if
UiElementInfogains or renames a property, nothing currently catches the schema silently drifting out of sync. - The JS/Playwright capture example is deliberately minimal and is not CI-wired against a live browser.
- The Python/pywinauto desktop example is CI-verified on
windows-latest, but was never run locally by the assistant that wrote it - no Windows/UI Automation access in that environment.
🇹🇷 Türkçe Kılavuz
Bu sitedeki diğer her rehber bir .NET projesi varsayar: bir paket referansı ekleyin, C# yazın, SelfHealingResolver‘ı süreç içinde çağırın. automation-sandbox-heal (AutomationSandbox.Cli) bu gereksinimi tamamen ortadan kaldırır. SelfHealingResolver.Resolve yalnızca framework’ten bağımsız UiElementInfo ağacı üzerinde çalışır - FlaUI yok, Playwright .NET SDK’sı yok, Windows bağımlılığı yok - yani “her dilden, her CI’dan” bu motora ulaşmanın önündeki tek gerçek engel paketlemeydi. Bu rehber tüm hikayeyi kapsar: CLI’nin kendisi, okuyup yazdığı JSON sözleşmesi, onu saran GitHub Action, ve C# dışında bir dil için çalışan gerçek bir yakalama örneği.
Kurulum
dotnet tool install -g AutomationSandbox.Cli --prerelease
0.x beta serisi boyunca --prerelease gereklidir; kararlı bir 1.0 yayınlandığında kaldırın. Bu hâlâ makinede .NET runtime’ının bulunmasını gerektirir - aracın kendisi gerçek bir .NET çalıştırılabilir dosyasıdır, sadece çağıranın bir .NET projesine ihtiyacı yoktur.
Temel Kullanım
automation-sandbox-heal --expected stale-element.json --tree live-tree.json --profile balanced
--expected- tek birUiElementInfoJSON nesnesi: eski/kırık locator’ın bilinen son hali.--tree- birUiElementInfoJSON ağacı: canlı uygulamanın taze bir anlık görüntüsü.--profile-balanced(varsayılan),conservative, veyaaggressive. Her birinin neyi değiş tokuş ettiği içinAGENTS.md‘deki healing-pipeline eşiklerine bakın.
Stdout’a bir HealResult JSON olarak basılır - bu projedeki her API yüzeyinin sergilediği aynı açıklanabilir ScoreComponents dökümü, RunnerUpScore, ve EvidenceCoverage. Tanılama günlükleri stderr’e gider, yani stdout her zaman saf, ayrıştırılabilir JSON’dur. Çıkış kodu 0 IsConfident anlamına gelir (Matched‘i kabul etmek güvenlidir); 1 yeterince emin olunmadığını gösterir (otomatik kabul etmeyin); 2 bir karara varılmadan önce bir hata oluştuğu anlamına gelir (kötü girdi, eksik dosya) - asla ham bir stack trace değil.
JSON Şeması
Her iki JSON girdisi de, aracın kendi çıktısı da yayınlanmış bir JSON Schema‘yı takip eder. Herhangi bir C# kaynağını okumadan otomatik tamamlama ve doğrulama için editörünüzü veya bir doğrulayıcıyı buna yönlendirin:
{
"$schema": "https://mustafasercansak.github.io/automation-sandbox/schemas/ui-element-info.schema.json",
"ControlType": "Button"
}
Yalnızca SimilarityScorer‘ın beş ağırlıklı sinyalinin (ControlType, Name, AutomationId, BoundingRectangle, ParentControlType) arkasındaki alanlar zorunludur; geri kalan her şey isteğe bağlıdır, bu da motorun bir özellik girdi JSON’unda yoksa başvurduğu C# varsayılanlarıyla eşleşir.
CI’da Kullanım: GitHub Action
Bir composite GitHub Action, kurulum, çalıştırma ve JSON ayrıştırma adımlarını tek bir satıra sarmalar:
- uses: mustafasercansak/automation-sandbox/.github/actions/heal@main
with:
expected: path/to/stale-element.json
tree: path/to/live-tree.json
profile: balanced
Varsayılan olarak bu adım, sonuç yeterince emin değilse job’u başarısız yapar - tıpkı CLI’nin kendi exit-code sözleşmesi gibi, yani sade bir uses: satırı zaten çalışan bir pass/fail kapısıdır. Build’i başarısız yapmak yerine sonuca göre dallanmak isterseniz continue-on-error: true ekleyin ve is-confident/result çıktılarını okuyun. İsteğe bağlı bir source girdisi, action’ın nuget.org yerine özel bir feed’den kurulum yapmasına izin verir.
Herhangi Bir Dilden JSON Yakalamak: Web (JS/Playwright)
CLI, ancak girdisini üreten bir şey olduğunda işe yarar. Depo bunun için gerçek, çalışan bir referans sunar: examples/js-playwright-capture, bir web sayfasının DOM’unu yukarıdaki tam JSON şeklinde yakalayan bir Node.js + Playwright betiği - AutomationSandbox.WebDiscovery‘nin .NET tarafında kullandığı aynı rol/erişilebilir-isim tespiti ve ControlType/AutomationId eşleme kurallarını yansıtır, böylece JS’de yakalanan bir ağaç .NET’te yakalanmış biriyle tutarlı puanlanır. Bilinçli olarak minimaldir (sadece normal DOM - Shadow DOM veya iframe gezinmesi yok), ve sıfır ağ bağımlılığıyla çalışması için birlikte gelen bir fixture içerir.
Herhangi Bir Dilden JSON Yakalamak: Masaüstü (Python/pywinauto)
Windows masaüstü uygulamaları için aynı fikir: examples/python-pywinauto-capture, pywinauto‘nun uia backend’ini kullanan bir Python betiği - FlaUI/UIA3‘ün kullandığı aynı Windows UI Automation COM API’si, yani sadece eşleşen bir JSON şekli değil, gerçekten eşdeğer veri üretir. JS örneğinin aksine, bu örnek bunu yazan asistan tarafından yerel olarak doğrulanamadı (o ortamda Windows/UI Automation erişimi yok) - gerçek doğrulaması, bu deponun kendi WinForms demo uygulamasını derleyen, başlatan, gerçek UI ağacını yakalayan ve automation-sandbox-heal‘in bu gerçek veriden oluşturulan sentetik bir eski locator’ı iyileştirdiğini doğrulayan bir CI job’udur (Desktop Capture (Python)).
Kendi araçlarınız zaten aynı şekilde bir dict üretiyorsa, minimal bir Python taslağı:
import json, subprocess
result = subprocess.run(
["automation-sandbox-heal", "--expected", "expected.json", "--tree", "tree.json", "--profile", "balanced"],
capture_output=True, text=True,
)
heal_result = json.loads(result.stdout)
if result.returncode == 0:
print(f"Healed: use {heal_result['Matched']['AutomationId']} instead")
Web Sitesinde Yazım Hatası Taramak: automation-sandbox-audit
İkinci bir araç, AutomationSandbox.SiteAudit (komut: automation-sandbox-audit), tek bir URL’den başlayarak siteyi gezer ve yazım hatalarını, tekrarlanan kelimeleri ve unutulmuş yer tutucu metinleri raporlar. API anahtarı gerektirmez ve sayfa metnini hiçbir yere göndermez: yazım denetimi, Türkçe gibi ek alan dilleri de işleyebilen Hunspell sözlüklerinden gelir. .NET 8 runtime’ı (veya daha yenisi) gerekir ve gezme için Chromium indirir.
automation-sandbox-audit --url https://example.com --lang tr,en --allow-word Playwright --install-browser
--langsözlükleri listeler, ana dil önce gelir (varsayılanen;en-GBgibi bölgesel varyantlar çalışır,enAmerikan imlasıdır vebehaviourkelimesini hatalı bulur). Listelenen sözlüklerden herhangi biri bir kelimeyi kabul ederse kelime doğru sayılır; bu, İngilizce terimler içeren Türkçe bir sayfaya uygundur. Bedeli: diğer dilde geçerli bir kelime olan bir yazım hatası raporlanmaz. Yabancı kelimelere gelen Türkçe ekler (artifact'ları) kök üzerinden değerlendirilir.--allow-word/--allow-filemarka ve ürün adlarını rapordan uzak tutar.- Sözlükler bir kez,
wooorm/dictionariesdeposunun sabitlenmiş bir commit’inden indirilir (pakete gömülü değildir) ve kullanıcıya özel bir önbelleğe konur;--no-downloadçevrimdışı kullanım için indirmeyi yasaklar. - Çıkış kodu
0bulgu yok,1bulgu var (CI adımı buna göre kapı olabilir),2tarama çalıştırılamadı (hatalı argüman, eksik sözlük, ulaşılamayan başlangıç sayfası) demektir.--output-diraltına bir JSON Lines günlüğü ve bir HTML rapor yazılır (her çalıştırmada üzerine yazılır). - Yalnızca tek tek kelimeleri değerlendirir. Dilbilgisi ve anlam bir sözlüğün erişiminin dışındadır; izin listesine eklemediğiniz marka adları, jargon ve kod yazım hatası olarak raporlanır. Metin, eleman başına 10.000 karaktere kadar denetlenir. Geliştirici belgesi sitelerinde çok sayıda yanlış alarm bekleyin (projenin kendi belgeleri: 31 sayfada 420 farklı işaretli kelime, çoğu
jsonvenugetgibi terimler; İngilizce sözlük küçüktür veintegrationsgibi çoğulları içermez); pazarlama ve içerik siteleri için çok daha uygundur, kalanını bir izin listesi halleder. - Henüz nuget.org’da yayımlanmadı; yayımlanana kadar depodan paketleyin (
dotnet pack TestAutomation/SiteAuditCli).Site Audit CLICI job’ı paketlenmiş aracı, gerçek Türkçe ve İngilizce sözlüklerle bir fixture sitesine karşı çalıştırır.
Yazım denetimini GitHub’da çalıştırmak
Bir composite action kurulum, çalıştırma, özet ve yükleme adımlarını sarar; böylece zamanlanmış bir workflow tek bir uses: satırıdır. API anahtarı gerektirmez ve sayfa metni runner’dan çıkmaz:
name: Typo audit
on:
schedule:
- cron: '0 6 * * 1'
workflow_dispatch:
jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: mustafasercansak/automation-sandbox/.github/actions/site-audit@main
with:
url: https://example.com
lang: tr,en
allow-words: |
Acme
Playwright
- Job özetine bir bulgu tablosu yazar ve JSON ile HTML raporunu artifact olarak yükler (atlamak için
upload-report: 'false', action aynı job’da iki kez çalışıyorsaartifact-name). - Varsayılan olarak bir şey bulunursa job başarısız olur. Yalnızca raporlamak için
fail-on-findings: 'false'verin veissue-countileexit-codeçıktılarını okuyarak dallanın. Çalıştırılamayan bir tarama (hatalı URL, eksik sözlük) her zaman başarısız olur; bozuk bir tarama hiçbir zaman temiz bir site gibi görünmez. - Araç henüz nuget.org’da olmadığından action onu kendi depo checkout’undan derler; yani araç sürümü, action’ı sabitlediğiniz ref’teki sürümdür. Tekrarlanabilir bir tarama için
@mainyerine bir etiket veya commit SHA’sı sabitleyin. Bu derleme yaklaşık bir dakika ekler. Bir sürüm yayımlandığındaversion:onu kurar. - Siteyi sunulduğu haliyle tarar, yani bir tarayıcının gördüğünü kapsar: yayına almadan sonra veya üretime karşı zamanlanmış olarak çalıştırın. Chromium’u araç kurar; tarayıcının sistem kütüphaneleri olmayan bir self-hosted runner’da önce onların kurulması gerekir.
Neden CLI, Sadece Kütüphane Değil
AutomationSandbox.SelfHealing/AutomationSandbox.UiModel, kendi UiElementInfo ağaçlarını zaten yakalayan (Discovery, WebDiscovery, veya elle yazılmış bir adaptör ile) ve resolver’ı süreç içinde çağırmak isteyen bir .NET projesi için doğru seçimdir. CLI, geri kalan her şey içindir: .NET dışı bir test paketi, bir CI pipeline’ındaki bir shell script, veya bir JSON ağacı üretebilen ama sadece bir healing kararı almak için .NET bağımlılığı almasına gerek olmayan herhangi bir araç.
Bilinen Sınırlamalar
- Yayınlanmış paket şu anda
0.xbeta serisi boyunca yalnızca--prereleasesürüm olarak gelir. - JSON Schema elle doğrulanır, CI tarafından zorunlu kılınmaz (bu deponun kendi araç seti C#/PowerShell ile sınırlı kalır) -
UiElementInfobir özellik kazanır veya yeniden adlandırılırsa, şemanın sessizce uyumsuzlaşmasını şu anda hiçbir şey yakalamaz. - JS/Playwright yakalama örneği bilinçli olarak minimaldir ve canlı bir tarayıcıya karşı CI’a bağlanmamıştır.
- Python/pywinauto masaüstü örneği
windows-latestüzerinde CI ile doğrulanmıştır, ama bunu yazan asistan tarafından yerel olarak hiç çalıştırılmadı - o ortamda Windows/UI Automation erişimi yok.