Stealth Chromium that passes every bot detection test. Drop-in Playwright replacement with source-level fingerprint patches. 50+ tests passed.
Python ai-agentsanti-detectantidetect-browserbot-detectionbrowser-automationcaptcha-bypasschromiumcloudflarecloudflare-bypassfingerprintheadless-browserplaywrightpuppeteerpythonrecaptchaseleniumstealth-browserundetectedweb-scrapingwebscraping
fix(humanize): select_option on emoji labels uses arrows; refuse on macOS
CloakHQa2e77639d7b4
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex c9eb4de..c3a938f 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -9,6 +9,7 @@ Changes are tagged: **[wrapper]** for Python/JS wrapper, **[binary]** for Chromi## [Unreleased]- **[wrapper]** Humanized `select_option()` on a dropdown now types the first letters of the option, like a person does on a long list, plus a few arrow keys when that is shorter, instead of pressing an arrow key once per row. A pick on a 200-option list takes about 1.5-2s instead of up to 30s, and `timeout=` now bounds it (#581). The keys typed land on the same option wherever the open popup's highlight starts, so a popup that opens under the mouse pointer no longer picks the wrong option on headed Linux (#580). On a macOS host the shortest unique prefix of the label is typed instead of the whole label. Python, JavaScript Playwright, and .NET.+- **[wrapper]** Humanized `select_option()` now reaches dropdown options whose label starts with an emoji (e.g. a flag before a country name) with arrow keys, because the browser's dropdown search ignores a typed emoji. On a macOS host, where the dropdown also ignores arrow keys, such an option raises a clear error that points to `page._original.select_option(...)` instead of failing with a mismatched selection. Python, JavaScript Playwright, and .NET.## [0.6.0] — 2026-10-08diff --git a/cloakbrowser/human/engine.py b/cloakbrowser/human/engine.pyindex 48b4ff7..4695547 100644--- a/cloakbrowser/human/engine.py+++ b/cloakbrowser/human/engine.py@@ -871,13 +871,18 @@ class Human:if state["current"] == index:await self.hover(target, {"_deadline": deadline, "human_config": opts.get("human_config")}, api=api)return- await self.click(target, {"_deadline": deadline, "force": opts.get("force"),- "human_config": opts.get("human_config")}, api=api)- await sleep_ms(rand(200, 450)) # popup opens; eyes find the optionmac = sys.platform == "darwin" # a macOS host's native popup ignores arrow keysplan = await self.worlds.call(r.frame, "typeAheadPlan", r.id, index, 0 if mac else 3)if plan is None:raise Error(f"{api}: Error: no option of this dropdown can be reached")+ if mac and plan.get("home") and any(ord(c) > 0xFFFF for c in plan["label"]):+ raise Error(f"{api}: Error: this option's label has an emoji or similar character that cannot be "+ "typed, and a macOS dropdown ignores arrow keys, so it cannot be picked with human "+ "input; select it with page._original.select_option(...) if a programmatic "+ "selection is acceptable")+ await self.click(target, {"_deadline": deadline, "force": opts.get("force"),+ "human_config": opts.get("human_config")}, api=api)+ await sleep_ms(rand(200, 450)) # popup opens; eyes find the optionif plan.get("home"):# No name prefix is unique (duplicate labels): Home, then walk; on# macOS type the whole label instead.diff --git a/cloakbrowser/human/world.py b/cloakbrowser/human/world.pyindex 2d5608a..f0010af 100644--- a/cloakbrowser/human/world.py+++ b/cloakbrowser/human/world.py@@ -266,6 +266,8 @@ const H = {const cost = k + Math.abs(n) + (a === target ? 0 : 1); // prefer the option's own nameif (best && cost >= best.cost) break;const s = keys[a].slice(0, k);+ // Blink takes one UTF-16 unit per key and drops a surrogate: an emoji can't be typed.+ if (/[\uD800-\uDFFF]/.test(s)) break;// A run of one letter ('aa', 'aaa') cycles from the highlighted row instead.if (/^(.)\1+$/.test(s) || s.endsWith(' ')) continue;if (unique(s) === a) { best = { cost, typed: s, arrows: n }; break; }diff --git a/dotnet/src/CloakBrowser/Human/HumanEngine.Actions.cs b/dotnet/src/CloakBrowser/Human/HumanEngine.Actions.csindex 562fe5f..cd4cb6d 100644--- a/dotnet/src/CloakBrowser/Human/HumanEngine.Actions.cs+++ b/dotnet/src/CloakBrowser/Human/HumanEngine.Actions.cs@@ -292,16 +292,21 @@ internal sealed partial class HumanEngineawait HoverAsync(t, new ActOpts { Deadline = d, HumanConfig = o.HumanConfig }, api).ConfigureAwait(false);return;}- await ClickAsync(t, new ActOpts { Deadline = d, Force = o.Force, HumanConfig = o.HumanConfig }, api).ConfigureAwait(false);- await Sleep(R(200, 450)).ConfigureAwait(false); // popup opens; eyes find the option- var cfg = CallCfg(o.HumanConfig);bool mac = OperatingSystem.IsMacOS(); // a macOS host's native popup ignores arrow keysvar ta = await World.CallAsync(r.Frame, "typeAheadPlan", r.Id, index.Value, mac ? 0 : 3).ConfigureAwait(false);if (ta is not { ValueKind: JsonValueKind.Object } p) throw Err($"{api}: Error: no option of this dropdown can be reached");+ bool viaHome = p.TryGetProperty("home", out var home) && home.GetBoolean();+ if (mac && viaHome && p.GetProperty("label").GetString()!.Any(char.IsSurrogate))+ throw Err($"{api}: Error: this option's label has an emoji or similar character that cannot be typed, and a " ++ "macOS dropdown ignores arrow keys, so it cannot be picked with human input; select it on the " ++ "original page (Humanize.Unwrap(page).SelectOptionAsync) if a programmatic selection is acceptable");+ await ClickAsync(t, new ActOpts { Deadline = d, Force = o.Force, HumanConfig = o.HumanConfig }, api).ConfigureAwait(false);+ await Sleep(R(200, 450)).ConfigureAwait(false); // popup opens; eyes find the option+ var cfg = CallCfg(o.HumanConfig);int n = p.GetProperty("arrows").GetInt32();var walk = Enumerable.Repeat(n > 0 ? "ArrowDown" : "ArrowUp", Math.Abs(n));var keys = new List<string>();- if (p.TryGetProperty("home", out var home) && home.GetBoolean())+ if (viaHome){// No name prefix is unique (duplicate labels): Home, then walk; on macOS type the whole label.if (mac) keys.AddRange(p.GetProperty("label").GetString()!.Select(c => c.ToString()));diff --git a/dotnet/src/CloakBrowser/Human/WorldHelpers.cs b/dotnet/src/CloakBrowser/Human/WorldHelpers.csindex 45d1a9f..83bcc5e 100644--- a/dotnet/src/CloakBrowser/Human/WorldHelpers.cs+++ b/dotnet/src/CloakBrowser/Human/WorldHelpers.cs@@ -243,6 +243,8 @@ const H = {const cost = k + Math.abs(n) + (a === target ? 0 : 1); // prefer the option's own nameif (best && cost >= best.cost) break;const s = keys[a].slice(0, k);+ // Blink takes one UTF-16 unit per key and drops a surrogate: an emoji can't be typed.+ if (/[\uD800-\uDFFF]/.test(s)) break;// A run of one letter ('aa', 'aaa') cycles from the highlighted row instead.if (/^(.)\1+$/.test(s) || s.endsWith(' ')) continue;if (unique(s) === a) { best = { cost, typed: s, arrows: n }; break; }diff --git a/dotnet/tests/CloakBrowser.Tests/HumanEngine/HumanEngineBrowserTests.cs b/dotnet/tests/CloakBrowser.Tests/HumanEngine/HumanEngineBrowserTests.csindex e1c8494..679605b 100644--- a/dotnet/tests/CloakBrowser.Tests/HumanEngine/HumanEngineBrowserTests.cs+++ b/dotnet/tests/CloakBrowser.Tests/HumanEngine/HumanEngineBrowserTests.cs@@ -361,11 +361,30 @@ public class HumanEngineBrowserTests : IClassFixture<EngineFixture>, IAsyncLifetvar keys = (await Events(p, "keydown")).Select(e => e.GetProperty("key").GetString()).ToList();Assert.DoesNotContain("ArrowDown", keys);Assert.True(keys.Count <= 13, string.Join(",", keys));- Assert.Equal("[\"input\",\"change\"]", await p.EvaluateAsync<string>("JSON.stringify(__sel)"));+ var sel = await p.EvaluateAsync<string[]>("__sel");+ // A macOS dropdown moves on every typed letter (one input/change each); elsewhere only Enter commits.+ Assert.Equal(new[] { "input", "change" }, sel.TakeLast(2));+ if (!OperatingSystem.IsMacOS()) Assert.Equal(2, sel.Length);await p.EvaluateAsync("document.querySelector('#long').selectedIndex = 0");await Assert.ThrowsAsync<TimeoutException>(() => p.SelectOptionAsync("#long", "v200", new() { Timeout = 200 }));}+ [BrowserFact]+ public async Task SelectOption_types_ahead_on_emoji_labels()+ {+ // Blink's type-ahead drops a typed emoji, so these options are reached with+ // arrows; a macOS popup ignores arrows, so there it refuses.+ var p = await Open();+ await p.EvaluateAsync(@"() => { const s = document.createElement('select'); s.id = 'emoji';+ for (const [l, v] of [['Pick one', ''], ['🍎 Apple', 'a'], ['🍌 Banana', 'b'], ['🍒 Cherry', 'c']]) s.add(new Option(l, v));+ document.body.append(s); }");+ if (OperatingSystem.IsMacOS())+ Assert.Contains("cannot be picked with human input",+ (await Assert.ThrowsAnyAsync<PlaywrightException>(() => p.SelectOptionAsync("#emoji", "c"))).Message);+ else+ Assert.Equal(new[] { "c" }, await p.SelectOptionAsync("#emoji", "c"));+ }+// --- frames / handles --------------------------------------------------[BrowserFact]diff --git a/js/src/human/engine.ts b/js/src/human/engine.tsindex 098e70c..729b656 100644--- a/js/src/human/engine.ts+++ b/js/src/human/engine.ts@@ -830,12 +830,17 @@ export class Human {await this.hover(target, { _deadline: deadline, human_config: opts.human_config }, api);return;}- await this.click(target, { _deadline: deadline, force: opts.force, human_config: opts.human_config }, api);- await sleepMs(rand(200, 450)); // popup opens; eyes find the option- const cfg = this.callCfg(opts.human_config);const mac = process.platform === 'darwin'; // a macOS host's native popup ignores arrow keysconst plan = await this.worlds.call(r.frame, 'typeAheadPlan', r.id, index, mac ? 0 : 3);if (!plan) throw err(`${api}: Error: no option of this dropdown can be reached`);+ if (mac && plan.home && /[\uD800-\uDFFF]/.test(plan.label)) {+ throw err(`${api}: Error: this option's label has an emoji or similar character that cannot be typed, and a `+ + 'macOS dropdown ignores arrow keys, so it cannot be picked with human input; select it with '+ + 'page._original.selectOption(...) if a programmatic selection is acceptable');+ }+ await this.click(target, { _deadline: deadline, force: opts.force, human_config: opts.human_config }, api);+ await sleepMs(rand(200, 450)); // popup opens; eyes find the option+ const cfg = this.callCfg(opts.human_config);const arrows = (n: number) => Array<string>(Math.abs(n)).fill(n > 0 ? 'ArrowDown' : 'ArrowUp');// No name prefix is unique (duplicate labels): Home, then walk; on macOS type the whole label.const keys: string[] = plan.home ? (mac ? [...plan.label] : ['Home', ...arrows(plan.arrows)])diff --git a/js/src/human/worldHelpers.ts b/js/src/human/worldHelpers.tsindex 246565f..23c42d7 100644--- a/js/src/human/worldHelpers.ts+++ b/js/src/human/worldHelpers.ts@@ -239,6 +239,8 @@ const H = {const cost = k + Math.abs(n) + (a === target ? 0 : 1); // prefer the option's own nameif (best && cost >= best.cost) break;const s = keys[a].slice(0, k);+ // Blink takes one UTF-16 unit per key and drops a surrogate: an emoji can't be typed.+ if (/[\uD800-\uDFFF]/.test(s)) break;// A run of one letter ('aa', 'aaa') cycles from the highlighted row instead.if (/^(.)\1+$/.test(s) || s.endsWith(' ')) continue;if (unique(s) === a) { best = { cost, typed: s, arrows: n }; break; }diff --git a/js/tests/humanizeEngine.test.ts b/js/tests/humanizeEngine.test.tsindex 30b70c4..ad5d28f 100644--- a/js/tests/humanizeEngine.test.ts+++ b/js/tests/humanizeEngine.test.ts@@ -349,12 +349,30 @@ describe.skipIf(!process.env.CLOAKBROWSER_BINARY_PATH)('humanize engine (real brconst keys = (await events(p, 'keydown')).map((e) => e.key);expect(keys).not.toContain('ArrowDown');expect(keys.length).toBeLessThanOrEqual(13);- expect(await p.evaluate(() => (window as any).__sel)).toEqual(['input', 'change']);+ const sel: string[] = await p.evaluate(() => (window as any).__sel);+ // A macOS dropdown moves on every typed letter (one input/change each); elsewhere only Enter commits.+ expect(sel.slice(-2)).toEqual(['input', 'change']);+ if (process.platform !== 'darwin') expect(sel).toHaveLength(2);await p.evaluate(() => { (document.querySelector('#long') as HTMLSelectElement).selectedIndex = 0; });const e = await p.selectOption('#long', 'v200', { timeout: 200 }).catch((x) => x);expect(e).toBeInstanceOf(errors.TimeoutError);});+ it('selectOption on emoji labels uses arrows, and refuses on macOS', async () => {+ // Blink's type-ahead drops a typed emoji; a macOS popup ignores arrows.+ const p = await open();+ await p.evaluate(() => {+ const s = document.createElement('select'); s.id = 'emoji';+ for (const [l, v] of [['Pick one', ''], ['🍎 Apple', 'a'], ['🍌 Banana', 'b'], ['🍒 Cherry', 'c']]) s.add(new Option(l, v));+ document.body.append(s);+ });+ if (process.platform === 'darwin') {+ await expect(p.selectOption('#emoji', 'c')).rejects.toThrow(/cannot be picked with human input/);+ } else {+ expect(await p.selectOption('#emoji', 'c')).toEqual(['c']);+ }+ });+// --- frames and handles ---------------------------------------------------it('frame actions', async () => {diff --git a/tests/test_humanize_engine.py b/tests/test_humanize_engine.pyindex e7d61b5..b63f891 100644--- a/tests/test_humanize_engine.py+++ b/tests/test_humanize_engine.py@@ -11,6 +11,7 @@ from __future__ import annotationsimport http.serverimport socketserver+import sysimport threadingimport timefrom typing import Any@@ -672,12 +673,28 @@ def test_select_option_on_a_long_dropdown_types_ahead(page):assert page.select_option("#long", "v150") == ["v150"]keys = [e["key"] for e in events(page, "keydown")]assert "ArrowDown" not in keys and len(keys) <= 13, keys- assert page.evaluate("__sel") == ["input", "change"]+ sel = page.evaluate("__sel")+ # A macOS dropdown moves on every typed letter (one input/change each); elsewhere only Enter commits.+ assert sel[-2:] == ["input", "change"] and (sys.platform == "darwin" or len(sel) == 2), selpage.evaluate("document.querySelector('#long').selectedIndex = 0")with pytest.raises(TimeoutError):page.select_option("#long", "v200", timeout=200)+def test_select_option_on_emoji_labels(page):+ """Blink's type-ahead drops a typed emoji, so these options are reached with+ arrows; a macOS popup ignores arrows, so there it refuses."""+ page.evaluate("""() => { const s = document.createElement('select'); s.id = 'emoji';+ for (const [l, v] of [['Pick one', ''], ['\U0001F34E Apple', 'a'], ['\U0001F34C Banana', 'b'],+ ['\U0001F352 Cherry', 'c']]) s.add(new Option(l, v));+ document.body.append(s); }""")+ if sys.platform == "darwin":+ with pytest.raises(Error, match="cannot be picked with human input"):+ page.select_option("#emoji", "c")+ else:+ assert page.select_option("#emoji", "c") == ["c"]++# --- frames and handles ------------------------------------------------------def test_frame_actions(page):