browser-tools 0.5.0__tar.gz → 0.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. {browser_tools-0.5.0 → browser_tools-0.7.0}/PKG-INFO +1 -1
  2. {browser_tools-0.5.0 → browser_tools-0.7.0}/pyproject.toml +1 -1
  3. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/GUIDE.txt +161 -1
  4. browser_tools-0.7.0/src/browser_tools/attached_session.py +135 -0
  5. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/cdp_client.py +0 -7
  6. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/cdp_handler.py +539 -50
  7. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/cli.py +433 -218
  8. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/cdp_client.py +24 -1
  9. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/curated.py +250 -70
  10. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/events.py +41 -21
  11. browser_tools-0.7.0/src/browser_tools/frame_manager.py +720 -0
  12. browser_tools-0.7.0/src/browser_tools/frame_sessions.py +401 -0
  13. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/list_verbs.py +29 -17
  14. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/one_shot.py +78 -1
  15. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/passthrough.py +19 -3
  16. browser_tools-0.7.0/src/browser_tools/step_list.py +412 -0
  17. browser_tools-0.7.0/src/browser_tools/step_run.py +267 -0
  18. browser_tools-0.7.0/tests/doubles.py +147 -0
  19. browser_tools-0.7.0/tests/test_attached_session.py +243 -0
  20. browser_tools-0.7.0/tests/test_core_send_timeout.py +216 -0
  21. browser_tools-0.7.0/tests/test_cross_origin_frames.py +156 -0
  22. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_curated_verbs.py +46 -2
  23. browser_tools-0.7.0/tests/test_error_prefix.py +71 -0
  24. browser_tools-0.7.0/tests/test_frame_session_discovery.py +321 -0
  25. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_guide.py +56 -0
  26. browser_tools-0.7.0/tests/test_handler_transport.py +221 -0
  27. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_interaction_targeting.py +13 -2
  28. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_list_verbs.py +4 -1
  29. browser_tools-0.7.0/tests/test_session_hygiene.py +1169 -0
  30. browser_tools-0.7.0/tests/test_shared_session.py +415 -0
  31. browser_tools-0.7.0/tests/test_step_dispatch.py +177 -0
  32. browser_tools-0.7.0/tests/test_step_list.py +525 -0
  33. browser_tools-0.7.0/tests/test_step_run.py +1278 -0
  34. browser_tools-0.5.0/src/browser_tools/frame_manager.py +0 -408
  35. {browser_tools-0.5.0 → browser_tools-0.7.0}/.gitignore +0 -0
  36. {browser_tools-0.5.0 → browser_tools-0.7.0}/LICENSE +0 -0
  37. {browser_tools-0.5.0 → browser_tools-0.7.0}/NOTICE +0 -0
  38. {browser_tools-0.5.0 → browser_tools-0.7.0}/README.md +0 -0
  39. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/__init__.py +0 -0
  40. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/camoufox_runner.py +0 -0
  41. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/cdp_constants.py +0 -0
  42. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/__init__.py +0 -0
  43. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/attach.py +0 -0
  44. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/connection.py +0 -0
  45. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/__init__.py +0 -0
  46. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/accessibility.py +0 -0
  47. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/animation.py +0 -0
  48. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/audits.py +0 -0
  49. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/autofill.py +0 -0
  50. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/background_service.py +0 -0
  51. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/bluetooth_emulation.py +0 -0
  52. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/browser.py +0 -0
  53. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/cache_storage.py +0 -0
  54. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/cast.py +0 -0
  55. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/console.py +0 -0
  56. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/css.py +0 -0
  57. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/debugger.py +0 -0
  58. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/device_access.py +0 -0
  59. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/device_orientation.py +0 -0
  60. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/dom.py +0 -0
  61. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/dom_debugger.py +0 -0
  62. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/dom_snapshot.py +0 -0
  63. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/dom_storage.py +0 -0
  64. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/emulation.py +0 -0
  65. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/event_breakpoints.py +0 -0
  66. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/extensions.py +0 -0
  67. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/fed_cm.py +0 -0
  68. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/fetch.py +0 -0
  69. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/file_system.py +0 -0
  70. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/headless_experimental.py +0 -0
  71. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/heap_profiler.py +0 -0
  72. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/indexed_db.py +0 -0
  73. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/input.py +0 -0
  74. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/inspector.py +0 -0
  75. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/io.py +0 -0
  76. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/layer_tree.py +0 -0
  77. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/log.py +0 -0
  78. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/media.py +0 -0
  79. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/memory.py +0 -0
  80. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/network.py +0 -0
  81. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/overlay.py +0 -0
  82. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/page.py +0 -0
  83. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/performance.py +0 -0
  84. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/performance_timeline.py +0 -0
  85. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/preload.py +0 -0
  86. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/profiler.py +0 -0
  87. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/pwa.py +0 -0
  88. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/runtime.py +0 -0
  89. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/schema.py +0 -0
  90. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/security.py +0 -0
  91. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/service_worker.py +0 -0
  92. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/smart_card_emulation.py +0 -0
  93. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/storage.py +0 -0
  94. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/system_info.py +0 -0
  95. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/target.py +0 -0
  96. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/tethering.py +0 -0
  97. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/tracing.py +0 -0
  98. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/web_audio.py +0 -0
  99. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/domains/web_authn.py +0 -0
  100. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/errors.py +0 -0
  101. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/fingerprint.py +0 -0
  102. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/instance_status.py +0 -0
  103. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/launcher.py +0 -0
  104. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/protocol.py +0 -0
  105. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/registry.py +0 -0
  106. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/supervisor.py +0 -0
  107. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/core/utils.py +0 -0
  108. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/detect_interstitial.js +0 -0
  109. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/endpoint.py +0 -0
  110. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/extras.py +0 -0
  111. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/interstitial.py +0 -0
  112. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/lifecycle.py +0 -0
  113. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/mcp_response.py +0 -0
  114. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/native_interaction.py +0 -0
  115. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/native_snapshot.py +0 -0
  116. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/process_utils.py +0 -0
  117. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/profiler.py +0 -0
  118. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/screencast.py +0 -0
  119. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/screenshot_utils.py +0 -0
  120. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/tool_registry.py +0 -0
  121. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/usage.py +0 -0
  122. {browser_tools-0.5.0 → browser_tools-0.7.0}/src/browser_tools/user_settings.py +0 -0
  123. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/conftest.py +0 -0
  124. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/parity/CORPUS.md +0 -0
  125. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/parity/camoufox_session.py +0 -0
  126. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/parity/conftest.py +0 -0
  127. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/parity/fixtures/dynamic.html +0 -0
  128. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/parity/fixtures/form.html +0 -0
  129. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/parity/fixtures/iframe.html +0 -0
  130. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/parity/fixtures/iframe_child.html +0 -0
  131. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/parity/fixtures/plain.html +0 -0
  132. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/parity/fixtures/shadow.html +0 -0
  133. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/parity/live_chromium.py +0 -0
  134. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/parity/node_broker.py +0 -0
  135. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/parity/parity_comparison.py +0 -0
  136. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/parity/parity_corpus.py +0 -0
  137. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/parity/parity_engines.py +0 -0
  138. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/parity/run_baseline.py +0 -0
  139. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/parity/test_camoufox_live_launch.py +0 -0
  140. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/parity/test_camoufox_session.py +0 -0
  141. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/parity/test_e2e_camoufox.py +0 -0
  142. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/parity/test_node_broker.py +0 -0
  143. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/parity/test_parity_baseline.py +0 -0
  144. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/parity/test_parity_corpus.py +0 -0
  145. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/parity/test_parity_engine.py +0 -0
  146. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/parity/test_parity_gate.py +0 -0
  147. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/parity/test_parity_native.py +0 -0
  148. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/parity/test_parity_native_interaction.py +0 -0
  149. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/parity/test_parity_operator.py +0 -0
  150. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_async_discovery.py +0 -0
  151. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_cdp_client.py +0 -0
  152. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_cli_grammar.py +0 -0
  153. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_cli_lifecycle.py +0 -0
  154. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_cli_surface.py +0 -0
  155. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_core_launcher.py +0 -0
  156. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_detached_tasks.py +0 -0
  157. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_diagnostics_name_real_verbs.py +0 -0
  158. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_endpoint.py +0 -0
  159. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_events.py +0 -0
  160. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_frame_manager.py +0 -0
  161. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_interstitial.py +0 -0
  162. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_native_backend.py +0 -0
  163. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_native_interaction.py +0 -0
  164. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_native_snapshot.py +0 -0
  165. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_new_tools.py +0 -0
  166. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_one_shot.py +0 -0
  167. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_packaging.py +0 -0
  168. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_passthrough.py +0 -0
  169. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_profile_liveness.py +0 -0
  170. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_profile_path_hardening.py +0 -0
  171. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_profile_root_move.py +0 -0
  172. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_profile_verbs.py +0 -0
  173. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_profiler.py +0 -0
  174. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_retained_contracts.py +0 -0
  175. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_stop_target.py +0 -0
  176. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_supervisor_document_liveness.py +0 -0
  177. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_supervisor_never_pauses.py +0 -0
  178. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_supervisor_profile_preservation.py +0 -0
  179. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_supervisor_visibility.py +0 -0
  180. {browser_tools-0.5.0 → browser_tools-0.7.0}/tests/test_window_marking.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: browser-tools
3
- Version: 0.5.0
3
+ Version: 0.7.0
4
4
  Summary: Browser automation, debugging, and anti-detect browsing CLI
5
5
  Project-URL: Homepage, https://github.com/dungle-scrubs/browser-tools
6
6
  Project-URL: Repository, https://github.com/dungle-scrubs/browser-tools
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "browser-tools"
3
- version = "0.5.0"
3
+ version = "0.7.0"
4
4
  description = "Browser automation, debugging, and anti-detect browsing CLI"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -160,6 +160,45 @@ CURATED VERBS
160
160
  Inspect and select page frames. PATTERN is a frame URL substring. Any
161
161
  other sub-action is a usage error (exit 2).
162
162
 
163
+ SAME-PROCESS FRAMES ONLY, unless you pass --frames all. A cross-origin
164
+ iframe runs in its own renderer process under Chrome's site isolation,
165
+ with its own CDP target. By default it is absent from `frames list`,
166
+ `frames select` cannot select it, and `snapshot` shows the Iframe node
167
+ with nothing under it. `--target` does not reach it either: only page
168
+ targets are attachable. Logins, payment forms and consent banners are
169
+ usually cross-origin iframes, so this is the common case rather than
170
+ the exotic one. `frames select` says so when it can tell that is what
171
+ happened.
172
+
173
+ --frames page | --frames all
174
+ Which frames the invocation can see. Default `page`, which is the
175
+ behaviour above. `all` attaches to each cross-origin iframe as well and
176
+ splices its frames into the one tree, so they are listed, selectable,
177
+ and readable by the verbs that take a selected frame.
178
+
179
+ Takes effect on `frames list`, `frames select`, `frames reset`,
180
+ `storage get`, `snapshot`, `click`, `fill`, and `run`, where it covers
181
+ every step of the run.
182
+
183
+ `frames list --frames all` marks a frame in another process
184
+ [out-of-process]. A frame past a bound is listed [unreachable] with its
185
+ URL rather than dropped, so a frame you cannot reach is still a row you
186
+ can see. The bounds are 32 frame sessions and 10 levels of nesting.
187
+
188
+ Off by default because it is opt-in for this release, not because it
189
+ costs much: measured over 9 runs each on a page with twenty sibling
190
+ cross-origin iframes, `frames list` took 109.2 ms by default and
191
+ 119.7 ms with --frames all. On a page with no cross-origin iframe the
192
+ flag costs one CDP round trip, about 8 ms.
193
+
194
+ It does not change what `snapshot` prints. A cross-origin iframe's
195
+ Iframe node still has nothing under it; merging the child trees is
196
+ later work. What --frames all gives you today is the frame, by name,
197
+ selectable, so `storage get`, `click` and `fill` can address it.
198
+
199
+ It does not change `screenshot` or `screencast` either. Neither is
200
+ frame-scoped; both capture the page, with or without the flag.
201
+
163
202
  storage get [--key K]
164
203
  The selected frame's storage. --key is a frame URL pattern to select
165
204
  before reading. It is NOT a cookie name or a local-storage key. Without
@@ -179,6 +218,126 @@ CURATED VERBS
179
218
  frames.
180
219
 
181
220
 
221
+ RUNNING MANY STEPS IN ONE INVOCATION
222
+
223
+ run FILE [--timeout SECONDS]
224
+ run - [--timeout SECONDS]
225
+ Run an ordered list of steps against one browser, in one invocation, over
226
+ one CDP connection. FILE is the list; `-` reads it from stdin. Takes
227
+ [INSTANCE] and --endpoint URL as above, and --target SPEC or --url
228
+ SUBSTRING to pick the page the whole run drives.
229
+
230
+ One step per line, each line a verb phrase exactly as you would type it
231
+ after the instance name. Blank lines and lines starting with # are
232
+ ignored; a # anywhere else is an ordinary character, so a URL fragment
233
+ or a --text value carrying one needs no quoting for that reason. Lines
234
+ are split the way a shell splits them, so quoting works as it does at
235
+ the prompt.
236
+
237
+ # select the checkout frame once, then read it twice
238
+ frames select checkout
239
+ storage get
240
+ Page.getNavigationHistory '{}'
241
+ snapshot
242
+
243
+ This is not a scripting language. There are no variables, no conditions,
244
+ no loops, and no way for one step to use another step's output. A run does
245
+ what the same commands would do one after another; it cannot decide
246
+ anything. Where you need a decision, read the output and run again.
247
+
248
+ A STEP IS A VERB, NOT AN INVOCATION. Steps may be: snapshot, click, fill,
249
+ wait-idle, wait-stable, wait, detect, console-list, network-list, frames,
250
+ storage get, screenshot, screencast, and any raw Domain.method. A step may
251
+ NOT name an instance, --endpoint, --target or --url: those belong to the
252
+ run, which resolves them once. attach is not a step (it runs until stdin
253
+ ends, so nothing could follow it), and neither are launch, status, stop,
254
+ cleanup, profile, window-border, guide, help or run itself. Any of these
255
+ in a step list is a usage error (exit 2).
256
+
257
+ FRAME SELECTION LASTS. `frames select` in one step governs the steps after
258
+ it, so `storage get` with no --key works inside a run. A selection
259
+ remembers the pattern you gave it, so after a navigation it re-points at
260
+ whatever frame now matches. If nothing matches any more, the selection is
261
+ cleared and the next frame-scoped step fails rather than reading the wrong
262
+ frame. The selected frame going away clears it too, but the pattern is
263
+ kept either way, so a later navigation that brings a matching frame back
264
+ selects it again. Only `frames reset` and a new `frames select` change the
265
+ pattern. `storage get --key` does not: the key names the frame for that
266
+ one read, and the selection is put back afterwards.
267
+
268
+ AFTER A NAVIGATION, WAIT BEFORE YOU READ. Page.navigate returns when the
269
+ navigation commits, and the frame tree updates from the event that
270
+ follows it. A step placed straight after a navigate can run before that
271
+ event arrives and see the frames of the page you just left. Put a
272
+ `wait-idle` step in between.
273
+
274
+ Use `wait-idle` and not `wait --event Page.loadEventFired` here. `wait`
275
+ reports events that arrive after it subscribes, and it subscribes when
276
+ its own step starts. A load that fired in the gap after the navigate step
277
+ is already gone, and the wait then times out on a page that has finished
278
+ loading. `wait-idle` reads the page's current state instead of waiting
279
+ for an edge, so it cannot miss one. It answers a narrower question than
280
+ `load` - the new document has stopped fetching - which is the question
281
+ this paragraph is about.
282
+
283
+ EVERYTHING ELSE BEHAVES AS IT WOULD ALONE, WITH ONE EXCEPTION. A step
284
+ inside a run does what the same command does on its own. Domains a step
285
+ turns on are turned off when that step ends, so a second `network-list`
286
+ in one run sees what the first one saw.
287
+
288
+ The exception is the Page and Runtime domains. A run needs them on
289
+ throughout to track frames, so they are never turned off between steps.
290
+ A step that relies on being the first to turn one of them on does not
291
+ get that. `wait --event Runtime.executionContextCreated` after any step
292
+ that touched Runtime reports nothing, where the same command on its own
293
+ reports the contexts that already exist; `console-list` is in the same
294
+ position, because it turns Runtime on too. Run either one on its own.
295
+
296
+ A raw step you write yourself is yours to undo. `Network.enable {}`
297
+ stays on until a later step turns it off; the rule above covers only the
298
+ domains a verb turns on for you. It wins over that rule where the two
299
+ meet: a `network-list` step after a hand-written `Network.enable` leaves
300
+ the domain on, because turning it off would make your step a no-op. The
301
+ price is that the `network-list` is not the first enable, the same
302
+ position Page and Runtime are already in.
303
+
304
+ The two exceptions are the run's own: `Page.disable` and
305
+ `Runtime.disable` are usage errors as steps (exit 2), because turning
306
+ either off breaks every step after it without failing any of them. Run
307
+ either on its own, outside a run.
308
+
309
+ UIDS ARE UNCHANGED. A UID is still valid until the page navigates, no
310
+ longer and no shorter. One process does not extend it. Because no step can
311
+ read another step's output, every UID in a step list is one you put there
312
+ from a snapshot you already read.
313
+
314
+ IT STOPS AT THE FIRST FAILURE, and nothing rolls back. A step that has run
315
+ has already reached the browser. Steps after the failure do not run.
316
+
317
+ --timeout SECONDS bounds the whole run; without it there is no whole-run
318
+ deadline, because every step already bounds itself. Use it when a step
319
+ opts out of its own bound, as `wait --timeout 0` does.
320
+
321
+ OUTPUT. One JSON document, on success and on failure alike: a `run` object
322
+ with the step count, how many completed, and the status; and a `steps`
323
+ array with one entry per step attempted, each carrying the JSON that step
324
+ would have printed alone. Steps never reached are absent.
325
+
326
+ READ IT IN THIS ORDER: the exit code, then `run.status`, then the steps.
327
+ A failed run still contains successful step entries, and each of those
328
+ carries exactly what that step prints on its own. If you parse the steps
329
+ without checking the exit code first, a run that died at step 7 reads
330
+ like a run that finished.
331
+
332
+ Exit 0 every step succeeded.
333
+ Exit 1 a step failed, or the run timed out. The document is still
334
+ printed, so you can see what already ran. This is the one verb
335
+ that prints on stdout when it exits 1.
336
+ Exit 2 the step list was malformed, or a step named an instance,
337
+ --endpoint, --target or --url. The whole list is checked before
338
+ the first step runs, so nothing ran.
339
+
340
+
182
341
  EVENT VERBS
183
342
 
184
343
  attach [INSTANCE] +Domain.event [+Domain.event ...]
@@ -504,6 +663,7 @@ OUTPUT AND EXIT CODES
504
663
  Exit 0 success.
505
664
  Exit 1 operational failure: the browser is gone, a CDP call failed, a
506
665
  deadline passed, a profile is held, a UID no longer resolves.
507
- Nothing is printed on stdout.
666
+ Nothing is printed on stdout, except by `run`, which prints its
667
+ run document so you can see which steps already ran.
508
668
  Exit 2 usage error: the invocation was malformed or refused before
509
669
  anything happened. Nothing was sent, written or deleted.
@@ -0,0 +1,135 @@
1
+ """The handler's client, backed by an attached Target session.
2
+
3
+ RFC-03 requires the run's **CDPRuntime**, and therefore its frame manager, to
4
+ sit on one flattened ``Target`` session of one browser-level CDP connection.
5
+ ``AttachedSessionClient`` is what puts it there: it presents
6
+ ``cdp_client.CDPClient``'s surface over ``core.cdp_client.CDPClient``, so what
7
+ a caller sends is unchanged and where it is sent changes.
8
+
9
+ Three properties the callers depend on, none of which the core client gives
10
+ on its own:
11
+
12
+ - **Session scope.** Every send carries the session, and every subscription
13
+ filters on it. A browser-level connection sees every attached target's
14
+ events; ``core/cdp_client.py`` delivers one only when the subscriber's
15
+ filter session matches.
16
+ - **A bounded command.** The core client defaults to no deadline. ``send``
17
+ asks it for 30 seconds, the bound the page-level client always applied. The
18
+ bound is passed down, not wrapped around the call: only the core ``send``
19
+ knows the message id, so only it can retire the pending entry when the wait
20
+ ends early. A ``wait_for`` out here leaves the entry behind, and the late
21
+ response lands on a cancelled future and kills the receive loop.
22
+ - **One exception type.** ``cdp_handler`` and ``screencast`` catch
23
+ ``cdp_client.CDPError``. The core client raises ``core.errors.CDPError``, an
24
+ unrelated class, and a bare ``ConnectionError``. Both are translated.
25
+
26
+ Ownership: ``one_shot_page_session`` opens the connection and the session and
27
+ closes both. This object closes neither.
28
+ """
29
+
30
+ from __future__ import annotations
31
+
32
+ import logging
33
+ from typing import TYPE_CHECKING, Any
34
+
35
+ from .cdp_client import CDPError
36
+ from .core.errors import CDPError as CoreCDPError
37
+
38
+ if TYPE_CHECKING:
39
+ from .core.cdp_client import CDPClient as CoreCDPClient
40
+
41
+ logger = logging.getLogger(__name__)
42
+
43
+ #: Matches ``cdp_client.CDPClient``'s default.
44
+ DEFAULT_TIMEOUT_SECONDS = 30.0
45
+
46
+
47
+ class AttachedSessionClient:
48
+ """``cdp_client.CDPClient``'s surface over one attached Target session."""
49
+
50
+ def __init__(self, client: CoreCDPClient, session_id: str) -> None:
51
+ self._client = client
52
+ self._session_id = session_id
53
+ self._closed = False
54
+ # Every handler this client registered, in order, so `off` can hand
55
+ # the core client back the same object it was given. See `off`.
56
+ self._subscriptions: list[tuple[str, Any]] = []
57
+
58
+ @property
59
+ def session_id(self) -> str:
60
+ """The attached session every send and subscription carries."""
61
+ return self._session_id
62
+
63
+ @property
64
+ def raw(self) -> CoreCDPClient:
65
+ """The browser-level client underneath, for a caller that needs it.
66
+
67
+ A Step Run executes the One-Shot Session verbs by calling their
68
+ ``*_on_session`` coroutines, which take the core client and a
69
+ ``sessionId`` rather than this adapter. They get them from here, so
70
+ every step still runs on the run's one session.
71
+ """
72
+ return self._client
73
+
74
+ @property
75
+ def connected(self) -> bool:
76
+ """Whether the underlying connection is usable."""
77
+ return not self._closed and bool(getattr(self._client, "_connected", False))
78
+
79
+ async def send(
80
+ self,
81
+ method: str,
82
+ params: dict[str, Any] | None = None,
83
+ timeout: float | None = None,
84
+ ) -> dict[str, Any]:
85
+ """Send one command over the attached session and return its result.
86
+
87
+ Raises ``CDPError`` for a protocol error, a lost connection and a
88
+ timeout alike.
89
+ """
90
+ if self._closed:
91
+ raise CDPError("Not connected to Chrome CDP")
92
+ deadline = DEFAULT_TIMEOUT_SECONDS if timeout is None else timeout
93
+ try:
94
+ return await self._client.send(
95
+ method=method,
96
+ params=params,
97
+ session_id=self._session_id,
98
+ timeout=deadline,
99
+ )
100
+ except CoreCDPError as exc:
101
+ raise CDPError(f"CDP error in {method}: {exc.message}") from exc
102
+ except TimeoutError as exc:
103
+ raise CDPError(f"CDP command timed out after {deadline}s: {method}") from exc
104
+ except ConnectionError as exc:
105
+ raise CDPError(f"Failed to send CDP command: {exc}") from exc
106
+
107
+ def on(self, event: str, handler: Any) -> None:
108
+ """Subscribe to an event on this session only."""
109
+ self._subscriptions.append((event, handler))
110
+ self._client.on(event, handler, session_id=self._session_id)
111
+
112
+ def off(self, event: str, handler: Any) -> None:
113
+ """Unsubscribe. A handler that was never registered is ignored.
114
+
115
+ Matching is by equality, which is what the page-level client did and
116
+ what callers rely on. The core client matches by identity, and
117
+ ``obj.method`` builds a fresh bound method on every access: equal to
118
+ the one registered, never the same object. ``ScreencastRecorder``
119
+ subscribes with ``self.on_frame`` and unsubscribes with
120
+ ``self.on_frame``, so identity matching would leave the subscription
121
+ in place and a reused recorder would double every frame.
122
+ """
123
+ for index, (registered_event, registered) in enumerate(self._subscriptions):
124
+ if registered_event == event and registered == handler:
125
+ del self._subscriptions[index]
126
+ self._client.off(event, registered)
127
+ return
128
+ self._client.off(event, handler)
129
+
130
+ async def disconnect(self) -> None:
131
+ """Mark this client unusable. The connection is not ours to close."""
132
+ self._closed = True
133
+
134
+
135
+ __all__ = ["DEFAULT_TIMEOUT_SECONDS", "AttachedSessionClient"]
@@ -357,13 +357,6 @@ def resolve_page_target_id(browser_url: str, target_spec: str) -> str | None:
357
357
  return _resolve_among(pages, target_spec)
358
358
 
359
359
 
360
- async def resolve_page_ws_url_async(
361
- browser_url: str, target_spec: str | None = None
362
- ) -> str | None:
363
- """Awaitable :func:`resolve_page_ws_url`, for callers on an event loop."""
364
- return await asyncio.to_thread(resolve_page_ws_url, browser_url, target_spec)
365
-
366
-
367
360
  async def get_page_ws_url_async(browser_url: str, page_index: int = 0) -> str | None:
368
361
  """Awaitable :func:`get_page_ws_url`, for callers on an event loop.
369
362