{"record":{"id":"a9a9612e98a08eee","repo":"CloakHQ/CloakBrowser","slug":"stealthevaluationerror-selector","errorCode":null,"errorMessage":"StealthEvaluationError: {selector}","messagePattern":"StealthEvaluationError: (.+?)","errorType":"exception","errorClass":"StealthEvaluationError","httpStatus":null,"severity":"error","filePath":"dotnet/src/CloakBrowser/Wrappers/LocatorHumanizer.cs","lineNumber":22,"sourceCode":"namespace CloakBrowser.Wrappers;\n\n/// <summary>Humanized locator actions. Direct page.Locator selectors use the canonical isolated DOM world; unknown locator shapes retain the legacy Playwright path.</summary>\ninternal static class LocatorHumanizer\n{\n    private static double RemainingMs(double deadline) => Actionability.RemainingMs(deadline);\n\n    private static async Task<IsolatedWorld> WorldAsync(HumanCursor cursor) =>\n        await cursor.GetStealthAsync().ConfigureAwait(false) ?? throw new StealthWorldUnavailableError();\n\n    internal static async Task<StealthSnapshot> SnapshotAsync(HumanCursor cursor, string selector)\n    {\n        var (status, snapshot) = await StealthDom.SnapshotAsync(await WorldAsync(cursor).ConfigureAwait(false), selector).ConfigureAwait(false);\n        return status switch\n        {\n            StealthStatus.Ok when snapshot != null => snapshot.Value,\n            StealthStatus.NotFound => throw new ElementNotAttachedError(selector),\n            StealthStatus.Unsupported => throw new UnsupportedHumanizeSelectorError(selector),\n            _ => throw new StealthEvaluationError(selector),\n        };\n    }\n\n    internal static async Task EnsureActionableAsync(HumanCursor cursor, string selector,\n        IReadOnlySet<string> checks, double timeout, bool force)\n    {\n        var world = await WorldAsync(cursor).ConfigureAwait(false);\n        await Actionability.EnsureActionableAsync(cursor.Page, selector, checks, timeout, force, world).ConfigureAwait(false);\n    }\n\n    private static async Task<BoundingBox?> GetBoxAsync(\n        IsolatedWorld world, string selector, double timeoutMs)\n    {\n        double deadline = System.Environment.TickCount64 + System.Math.Max(0, timeoutMs);\n        var result = await StealthDom.BoxAsync(world, selector).ConfigureAwait(false);\n        while ((result.Status == StealthStatus.NotFound || result.Status == StealthStatus.EvaluationFailed)\n            && System.Environment.TickCount64 < deadline)\n        {","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/CloakHQ/CloakBrowser/blob/d6bad5de261bedf025280ace1d14e800aee13923/dotnet/src/CloakBrowser/Wrappers/LocatorHumanizer.cs#L4-L40","documentation":"StealthEvaluationError mapped from an unrecognized StealthStatus (or Ok with null snapshot) in LocatorHumanizer.SnapshotAsync: the stealth-world snapshot for the selector failed in a way that isn't NotFound or Unsupported — the evaluation itself errored or returned malformed data.","triggerScenarios":"The isolated-world snapshot JS throwing or returning invalid JSON during navigation, page crash, or context teardown while a humanized locator action runs.","commonSituations":"Races with navigation/redirects, pages under heavy load timing out script execution, or calls issued while the page is closing.","solutions":["Wait for load state / network idle before the humanized action","Check page.IsClosed and context validity first","Retry once — transient evaluation races are common around navigation","If it persists, capture the stealth world state to see whether scripts are intact"],"exampleFix":"// before\nawait page.Locator(\"#x\").HumanClickAsync();\n\n// after\nawait page.WaitForLoadStateAsync(LoadState.DOMContentLoaded);\nawait page.Locator(\"#x\").HumanClickAsync();","handlingStrategy":"retry","validationCode":"await page.WaitForLoadStateAsync(LoadState.DOMContentLoaded);\nif (page.IsClosed) return;","typeGuard":null,"tryCatchPattern":"catch (StealthEvaluationError) when (transient) { await Task.Delay(250); retry once; }","preventionTips":["Wait for load state before humanized actions","Guard with IsClosed","Treat persistent StealthEvaluationError as a broken stealth install"],"tags":["stealth","evaluation","race-condition","locator"],"backgroundTag":"js-evaluation-failed","analyzedSha":"d6bad5de261bedf025280ace1d14e800aee13923","analyzedAt":"2026-08-28T14:13:12.918Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}