diff --git a/tests/tools/test_computer_use.py b/tests/tools/test_computer_use.py index 65dce0aead..737a503f51 100644 --- a/tests/tools/test_computer_use.py +++ b/tests/tools/test_computer_use.py @@ -2228,6 +2228,17 @@ class TestElementTokenAttachment: # The matching token rode along — cua-driver will prefer it. assert args["element_token"] == "s0001:5" + def test_token_attached_when_only_input_schema_advertises_it(self): + """cua-driver >= 0.21 dropped the per-tool `capabilities[]` array from tools/list but advertises + `element_token` in `click`'s inputSchema and REFUSES a bare element_index (`snapshot_id_required`). + The token must ride along from the live schema alone, or every element click is refused.""" + backend = self._backend_with_session({}) # no capabilities[] at all — the modern shape + backend._session.supports_input_property = lambda tool, prop: (tool, prop) == ("click", "element_token") + backend._snapshot_tokens = {5: "s00000001:5"} + backend.click(element=5, button="left") + _, args = backend._session.call_tool.call_args.args + assert args["element_token"] == "s00000001:5" + def test_capture_refreshes_snapshot_tokens(self): """A fresh capture should overwrite any stale tokens from a