osn-selenium 0.0.0__py3-none-any.whl → 1.0.0__py3-none-any.whl

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 (628) hide show
  1. osn_selenium/_functions.py +84 -0
  2. osn_selenium/_typehints.py +19 -0
  3. osn_selenium/abstract/executors/cdp/__init__.py +435 -0
  4. osn_selenium/abstract/executors/cdp/accessibility.py +62 -0
  5. osn_selenium/abstract/executors/cdp/animation.py +47 -0
  6. osn_selenium/abstract/executors/cdp/audits.py +39 -0
  7. osn_selenium/abstract/executors/cdp/autofill.py +34 -0
  8. osn_selenium/abstract/executors/cdp/background_service.py +22 -0
  9. osn_selenium/abstract/executors/cdp/bluetooth_emulation.py +95 -0
  10. osn_selenium/abstract/executors/cdp/browser.py +122 -0
  11. osn_selenium/abstract/executors/cdp/cache_storage.py +49 -0
  12. osn_selenium/abstract/executors/cdp/cast.py +31 -0
  13. osn_selenium/abstract/executors/cdp/console.py +18 -0
  14. osn_selenium/abstract/executors/cdp/css.py +197 -0
  15. osn_selenium/abstract/executors/cdp/debugger.py +198 -0
  16. osn_selenium/abstract/executors/cdp/device_access.py +22 -0
  17. osn_selenium/abstract/executors/cdp/device_orientation.py +14 -0
  18. osn_selenium/abstract/executors/cdp/dom.py +305 -0
  19. osn_selenium/abstract/executors/cdp/dom_debugger.py +57 -0
  20. osn_selenium/abstract/executors/cdp/dom_snapshot.py +42 -0
  21. osn_selenium/abstract/executors/cdp/dom_storage.py +31 -0
  22. osn_selenium/abstract/executors/cdp/emulation.py +259 -0
  23. osn_selenium/abstract/executors/cdp/event_breakpoints.py +18 -0
  24. osn_selenium/abstract/executors/cdp/extensions.py +31 -0
  25. osn_selenium/abstract/executors/cdp/fed_cm.py +35 -0
  26. osn_selenium/abstract/executors/cdp/fetch.py +76 -0
  27. osn_selenium/abstract/executors/cdp/file_system.py +11 -0
  28. osn_selenium/abstract/executors/cdp/headless_experimental.py +30 -0
  29. osn_selenium/abstract/executors/cdp/heap_profiler.py +73 -0
  30. osn_selenium/abstract/executors/cdp/indexed_db.py +99 -0
  31. osn_selenium/abstract/executors/cdp/input.py +158 -0
  32. osn_selenium/abstract/executors/cdp/inspector.py +14 -0
  33. osn_selenium/abstract/executors/cdp/io.py +24 -0
  34. osn_selenium/abstract/executors/cdp/layer_tree.py +61 -0
  35. osn_selenium/abstract/executors/cdp/log.py +27 -0
  36. osn_selenium/abstract/executors/cdp/media.py +14 -0
  37. osn_selenium/abstract/executors/cdp/memory.py +61 -0
  38. osn_selenium/abstract/executors/cdp/network.py +252 -0
  39. osn_selenium/abstract/executors/cdp/overlay.py +166 -0
  40. osn_selenium/abstract/executors/cdp/page.py +347 -0
  41. osn_selenium/abstract/executors/cdp/performance.py +28 -0
  42. osn_selenium/abstract/executors/cdp/performance_timeline.py +11 -0
  43. osn_selenium/abstract/executors/cdp/preload.py +14 -0
  44. osn_selenium/abstract/executors/cdp/profiler.py +54 -0
  45. osn_selenium/abstract/executors/cdp/pwa.py +46 -0
  46. osn_selenium/abstract/executors/cdp/runtime.py +176 -0
  47. osn_selenium/abstract/executors/cdp/schema.py +11 -0
  48. osn_selenium/abstract/executors/cdp/security.py +26 -0
  49. osn_selenium/abstract/executors/cdp/service_worker.py +54 -0
  50. osn_selenium/abstract/executors/cdp/storage.py +175 -0
  51. osn_selenium/abstract/executors/cdp/system_info.py +24 -0
  52. osn_selenium/abstract/executors/cdp/target.py +125 -0
  53. osn_selenium/abstract/executors/cdp/tethering.py +14 -0
  54. osn_selenium/abstract/executors/cdp/tracing.py +48 -0
  55. osn_selenium/abstract/executors/cdp/web_audio.py +19 -0
  56. osn_selenium/abstract/executors/cdp/web_authn.py +76 -0
  57. osn_selenium/abstract/executors/javascript.py +203 -0
  58. osn_selenium/abstract/instances/action_chains/__init__.py +12 -0
  59. osn_selenium/abstract/instances/action_chains/base.py +25 -0
  60. osn_selenium/abstract/instances/action_chains/click.py +93 -0
  61. osn_selenium/abstract/instances/action_chains/drag_and_drop.py +46 -0
  62. osn_selenium/abstract/instances/action_chains/hm_keyboard.py +44 -0
  63. osn_selenium/abstract/instances/action_chains/hm_move.py +104 -0
  64. osn_selenium/abstract/instances/action_chains/hm_scroll.py +75 -0
  65. osn_selenium/abstract/instances/action_chains/keyboard.py +79 -0
  66. osn_selenium/abstract/instances/action_chains/move.py +60 -0
  67. osn_selenium/abstract/instances/action_chains/scroll.py +61 -0
  68. osn_selenium/abstract/instances/action_chains/utils.py +44 -0
  69. osn_selenium/abstract/instances/alert.py +67 -0
  70. osn_selenium/abstract/instances/browser.py +76 -0
  71. osn_selenium/abstract/instances/browsing_context.py +310 -0
  72. osn_selenium/abstract/instances/dialog.py +107 -0
  73. osn_selenium/abstract/instances/fedcm.py +133 -0
  74. osn_selenium/abstract/instances/mobile.py +79 -0
  75. osn_selenium/abstract/instances/network.py +100 -0
  76. osn_selenium/abstract/instances/permissions.py +52 -0
  77. osn_selenium/abstract/instances/script.py +109 -0
  78. osn_selenium/abstract/instances/shadow_root.py +81 -0
  79. osn_selenium/abstract/instances/storage.py +98 -0
  80. osn_selenium/abstract/instances/switch_to.py +104 -0
  81. osn_selenium/abstract/instances/web_driver_wait.py +57 -0
  82. osn_selenium/abstract/instances/web_element.py +395 -0
  83. osn_selenium/abstract/instances/web_extension.py +70 -0
  84. osn_selenium/abstract/webdriver/blink/__init__.py +18 -0
  85. osn_selenium/abstract/webdriver/blink/base.py +80 -0
  86. osn_selenium/abstract/webdriver/blink/casting.py +82 -0
  87. osn_selenium/abstract/webdriver/blink/features.py +51 -0
  88. osn_selenium/abstract/webdriver/blink/lifecycle.py +76 -0
  89. osn_selenium/abstract/webdriver/blink/logging.py +40 -0
  90. osn_selenium/abstract/webdriver/blink/network.py +45 -0
  91. osn_selenium/abstract/webdriver/blink/settings.py +68 -0
  92. osn_selenium/abstract/webdriver/chrome/__init__.py +18 -0
  93. osn_selenium/abstract/webdriver/chrome/base.py +36 -0
  94. osn_selenium/abstract/webdriver/chrome/lifecycle.py +92 -0
  95. osn_selenium/abstract/webdriver/chrome/settings.py +110 -0
  96. osn_selenium/abstract/webdriver/core/__init__.py +16 -0
  97. osn_selenium/abstract/webdriver/core/actions.py +58 -0
  98. osn_selenium/abstract/webdriver/core/auth.py +145 -0
  99. osn_selenium/abstract/webdriver/core/base.py +298 -0
  100. osn_selenium/abstract/webdriver/core/capture.py +84 -0
  101. osn_selenium/abstract/webdriver/core/components.py +82 -0
  102. osn_selenium/abstract/webdriver/core/devtools.py +69 -0
  103. osn_selenium/abstract/webdriver/core/element.py +55 -0
  104. osn_selenium/abstract/webdriver/core/file.py +82 -0
  105. osn_selenium/abstract/webdriver/core/lifecycle.py +103 -0
  106. osn_selenium/abstract/webdriver/core/navigation.py +65 -0
  107. osn_selenium/abstract/webdriver/core/script.py +88 -0
  108. osn_selenium/abstract/webdriver/core/settings.py +43 -0
  109. osn_selenium/abstract/webdriver/core/storage.py +81 -0
  110. osn_selenium/abstract/webdriver/core/timeouts.py +101 -0
  111. osn_selenium/abstract/webdriver/core/window.py +237 -0
  112. osn_selenium/abstract/webdriver/edge/__init__.py +18 -0
  113. osn_selenium/abstract/webdriver/edge/base.py +36 -0
  114. osn_selenium/abstract/webdriver/edge/lifecycle.py +92 -0
  115. osn_selenium/abstract/webdriver/edge/settings.py +110 -0
  116. osn_selenium/abstract/webdriver/yandex/__init__.py +18 -0
  117. osn_selenium/abstract/webdriver/yandex/base.py +18 -0
  118. osn_selenium/abstract/webdriver/yandex/lifecycle.py +92 -0
  119. osn_selenium/abstract/webdriver/yandex/settings.py +110 -0
  120. osn_selenium/base_mixin.py +122 -0
  121. osn_selenium/browsers_handler/__init__.py +47 -17
  122. osn_selenium/browsers_handler/_linux.py +226 -0
  123. osn_selenium/browsers_handler/_windows.py +21 -14
  124. osn_selenium/browsers_handler/{types.py → models.py} +5 -2
  125. osn_selenium/dev_tools/_decorators.py +140 -0
  126. osn_selenium/dev_tools/_exception_helpers.py +116 -0
  127. osn_selenium/dev_tools/_functions.py +174 -0
  128. osn_selenium/dev_tools/_system_utils.py +35 -0
  129. osn_selenium/dev_tools/_typehints.py +32 -0
  130. osn_selenium/dev_tools/_validators.py +227 -0
  131. osn_selenium/dev_tools/_wrappers.py +95 -0
  132. osn_selenium/dev_tools/domains/__init__.py +7 -40
  133. osn_selenium/dev_tools/domains/abstract.py +98 -254
  134. osn_selenium/dev_tools/domains/fetch.py +229 -906
  135. osn_selenium/dev_tools/domains_default/fetch.py +40 -28
  136. osn_selenium/dev_tools/filters.py +40 -0
  137. osn_selenium/dev_tools/logger/main.py +226 -0
  138. osn_selenium/dev_tools/logger/models.py +232 -0
  139. osn_selenium/dev_tools/logger/target.py +258 -0
  140. osn_selenium/dev_tools/manager/__init__.py +16 -0
  141. osn_selenium/dev_tools/manager/base.py +147 -0
  142. osn_selenium/dev_tools/manager/lifecycle.py +236 -0
  143. osn_selenium/dev_tools/manager/logging.py +153 -0
  144. osn_selenium/dev_tools/manager/settings.py +89 -0
  145. osn_selenium/dev_tools/manager/targets.py +175 -0
  146. osn_selenium/dev_tools/models.py +49 -0
  147. osn_selenium/dev_tools/settings.py +135 -0
  148. osn_selenium/dev_tools/target/__init__.py +16 -0
  149. osn_selenium/dev_tools/target/base.py +438 -0
  150. osn_selenium/dev_tools/target/detach.py +54 -0
  151. osn_selenium/dev_tools/target/discovery.py +112 -0
  152. osn_selenium/dev_tools/target/events.py +120 -0
  153. osn_selenium/dev_tools/target/fingerprint.py +126 -0
  154. osn_selenium/dev_tools/target/lifecycle.py +179 -0
  155. osn_selenium/dev_tools/target/logging.py +155 -0
  156. osn_selenium/exceptions/__init__.py +1 -0
  157. osn_selenium/exceptions/base.py +9 -0
  158. osn_selenium/exceptions/configuration.py +84 -0
  159. osn_selenium/exceptions/devtools.py +114 -0
  160. osn_selenium/exceptions/flags.py +45 -0
  161. osn_selenium/exceptions/instance.py +92 -0
  162. osn_selenium/exceptions/javascript.py +31 -0
  163. osn_selenium/exceptions/logic.py +31 -0
  164. osn_selenium/exceptions/path.py +77 -0
  165. osn_selenium/exceptions/platform.py +33 -0
  166. osn_selenium/exceptions/protocol.py +86 -0
  167. osn_selenium/exceptions/webdriver.py +44 -0
  168. osn_selenium/exceptions/window.py +63 -0
  169. osn_selenium/executors/__init__.py +1 -0
  170. osn_selenium/executors/sync/__init__.py +1 -0
  171. osn_selenium/executors/sync/cdp/__init__.py +550 -0
  172. osn_selenium/executors/sync/cdp/accessibility.py +74 -0
  173. osn_selenium/executors/sync/cdp/animation.py +50 -0
  174. osn_selenium/executors/sync/cdp/audits.py +48 -0
  175. osn_selenium/executors/sync/cdp/autofill.py +39 -0
  176. osn_selenium/executors/sync/cdp/background_service.py +30 -0
  177. osn_selenium/executors/sync/cdp/bluetooth_emulation.py +101 -0
  178. osn_selenium/executors/sync/cdp/browser.py +131 -0
  179. osn_selenium/executors/sync/cdp/cache_storage.py +66 -0
  180. osn_selenium/executors/sync/cdp/cast.py +38 -0
  181. osn_selenium/executors/sync/cdp/console.py +24 -0
  182. osn_selenium/executors/sync/cdp/css.py +187 -0
  183. osn_selenium/executors/sync/cdp/debugger.py +206 -0
  184. osn_selenium/executors/sync/cdp/device_access.py +27 -0
  185. osn_selenium/executors/sync/cdp/device_orientation.py +24 -0
  186. osn_selenium/executors/sync/cdp/dom.py +310 -0
  187. osn_selenium/executors/sync/cdp/dom_debugger.py +56 -0
  188. osn_selenium/executors/sync/cdp/dom_snapshot.py +58 -0
  189. osn_selenium/executors/sync/cdp/dom_storage.py +38 -0
  190. osn_selenium/executors/sync/cdp/emulation.py +270 -0
  191. osn_selenium/executors/sync/cdp/event_breakpoints.py +27 -0
  192. osn_selenium/executors/sync/cdp/extensions.py +39 -0
  193. osn_selenium/executors/sync/cdp/fed_cm.py +45 -0
  194. osn_selenium/executors/sync/cdp/fetch.py +96 -0
  195. osn_selenium/executors/sync/cdp/file_system.py +18 -0
  196. osn_selenium/executors/sync/cdp/headless_experimental.py +44 -0
  197. osn_selenium/executors/sync/cdp/heap_profiler.py +89 -0
  198. osn_selenium/executors/sync/cdp/indexed_db.py +142 -0
  199. osn_selenium/executors/sync/cdp/input.py +233 -0
  200. osn_selenium/executors/sync/cdp/inspector.py +21 -0
  201. osn_selenium/executors/sync/cdp/io.py +33 -0
  202. osn_selenium/executors/sync/cdp/layer_tree.py +71 -0
  203. osn_selenium/executors/sync/cdp/log.py +35 -0
  204. osn_selenium/executors/sync/cdp/media.py +21 -0
  205. osn_selenium/executors/sync/cdp/memory.py +62 -0
  206. osn_selenium/executors/sync/cdp/network.py +287 -0
  207. osn_selenium/executors/sync/cdp/overlay.py +174 -0
  208. osn_selenium/executors/sync/cdp/page.py +365 -0
  209. osn_selenium/executors/sync/cdp/performance.py +33 -0
  210. osn_selenium/executors/sync/cdp/performance_timeline.py +26 -0
  211. osn_selenium/executors/sync/cdp/preload.py +21 -0
  212. osn_selenium/executors/sync/cdp/profiler.py +58 -0
  213. osn_selenium/executors/sync/cdp/pwa.py +55 -0
  214. osn_selenium/executors/sync/cdp/runtime.py +221 -0
  215. osn_selenium/executors/sync/cdp/schema.py +23 -0
  216. osn_selenium/executors/sync/cdp/security.py +30 -0
  217. osn_selenium/executors/sync/cdp/service_worker.py +56 -0
  218. osn_selenium/executors/sync/cdp/storage.py +151 -0
  219. osn_selenium/executors/sync/cdp/system_info.py +30 -0
  220. osn_selenium/executors/sync/cdp/target.py +147 -0
  221. osn_selenium/executors/sync/cdp/tethering.py +21 -0
  222. osn_selenium/executors/sync/cdp/tracing.py +62 -0
  223. osn_selenium/executors/sync/cdp/web_audio.py +24 -0
  224. osn_selenium/executors/sync/cdp/web_authn.py +82 -0
  225. osn_selenium/executors/sync/javascript.py +79 -0
  226. osn_selenium/executors/trio_threads/__init__.py +1 -0
  227. osn_selenium/executors/trio_threads/cdp/__init__.py +771 -0
  228. osn_selenium/executors/trio_threads/cdp/accessibility.py +87 -0
  229. osn_selenium/executors/trio_threads/cdp/animation.py +63 -0
  230. osn_selenium/executors/trio_threads/cdp/audits.py +57 -0
  231. osn_selenium/executors/trio_threads/cdp/autofill.py +52 -0
  232. osn_selenium/executors/trio_threads/cdp/background_service.py +40 -0
  233. osn_selenium/executors/trio_threads/cdp/bluetooth_emulation.py +111 -0
  234. osn_selenium/executors/trio_threads/cdp/browser.py +140 -0
  235. osn_selenium/executors/trio_threads/cdp/cache_storage.py +79 -0
  236. osn_selenium/executors/trio_threads/cdp/cast.py +47 -0
  237. osn_selenium/executors/trio_threads/cdp/console.py +33 -0
  238. osn_selenium/executors/trio_threads/cdp/css.py +196 -0
  239. osn_selenium/executors/trio_threads/cdp/debugger.py +219 -0
  240. osn_selenium/executors/trio_threads/cdp/device_access.py +40 -0
  241. osn_selenium/executors/trio_threads/cdp/device_orientation.py +34 -0
  242. osn_selenium/executors/trio_threads/cdp/dom.py +319 -0
  243. osn_selenium/executors/trio_threads/cdp/dom_debugger.py +69 -0
  244. osn_selenium/executors/trio_threads/cdp/dom_snapshot.py +71 -0
  245. osn_selenium/executors/trio_threads/cdp/dom_storage.py +51 -0
  246. osn_selenium/executors/trio_threads/cdp/emulation.py +283 -0
  247. osn_selenium/executors/trio_threads/cdp/event_breakpoints.py +37 -0
  248. osn_selenium/executors/trio_threads/cdp/extensions.py +52 -0
  249. osn_selenium/executors/trio_threads/cdp/fed_cm.py +54 -0
  250. osn_selenium/executors/trio_threads/cdp/fetch.py +105 -0
  251. osn_selenium/executors/trio_threads/cdp/file_system.py +31 -0
  252. osn_selenium/executors/trio_threads/cdp/headless_experimental.py +54 -0
  253. osn_selenium/executors/trio_threads/cdp/heap_profiler.py +102 -0
  254. osn_selenium/executors/trio_threads/cdp/indexed_db.py +155 -0
  255. osn_selenium/executors/trio_threads/cdp/input.py +242 -0
  256. osn_selenium/executors/trio_threads/cdp/inspector.py +34 -0
  257. osn_selenium/executors/trio_threads/cdp/io.py +42 -0
  258. osn_selenium/executors/trio_threads/cdp/layer_tree.py +84 -0
  259. osn_selenium/executors/trio_threads/cdp/log.py +44 -0
  260. osn_selenium/executors/trio_threads/cdp/media.py +30 -0
  261. osn_selenium/executors/trio_threads/cdp/memory.py +71 -0
  262. osn_selenium/executors/trio_threads/cdp/network.py +296 -0
  263. osn_selenium/executors/trio_threads/cdp/overlay.py +183 -0
  264. osn_selenium/executors/trio_threads/cdp/page.py +374 -0
  265. osn_selenium/executors/trio_threads/cdp/performance.py +46 -0
  266. osn_selenium/executors/trio_threads/cdp/performance_timeline.py +36 -0
  267. osn_selenium/executors/trio_threads/cdp/preload.py +30 -0
  268. osn_selenium/executors/trio_threads/cdp/profiler.py +71 -0
  269. osn_selenium/executors/trio_threads/cdp/pwa.py +64 -0
  270. osn_selenium/executors/trio_threads/cdp/runtime.py +230 -0
  271. osn_selenium/executors/trio_threads/cdp/schema.py +32 -0
  272. osn_selenium/executors/trio_threads/cdp/security.py +43 -0
  273. osn_selenium/executors/trio_threads/cdp/service_worker.py +69 -0
  274. osn_selenium/executors/trio_threads/cdp/storage.py +162 -0
  275. osn_selenium/executors/trio_threads/cdp/system_info.py +43 -0
  276. osn_selenium/executors/trio_threads/cdp/target.py +156 -0
  277. osn_selenium/executors/trio_threads/cdp/tethering.py +34 -0
  278. osn_selenium/executors/trio_threads/cdp/tracing.py +71 -0
  279. osn_selenium/executors/trio_threads/cdp/web_audio.py +37 -0
  280. osn_selenium/executors/trio_threads/cdp/web_authn.py +95 -0
  281. osn_selenium/executors/trio_threads/javascript.py +90 -0
  282. osn_selenium/executors/unified/__init__.py +1 -0
  283. osn_selenium/executors/unified/cdp/__init__.py +1 -0
  284. osn_selenium/executors/unified/cdp/accessibility.py +81 -0
  285. osn_selenium/executors/unified/cdp/animation.py +50 -0
  286. osn_selenium/executors/unified/cdp/audits.py +45 -0
  287. osn_selenium/executors/unified/cdp/autofill.py +41 -0
  288. osn_selenium/executors/unified/cdp/background_service.py +24 -0
  289. osn_selenium/executors/unified/cdp/bluetooth_emulation.py +132 -0
  290. osn_selenium/executors/unified/cdp/browser.py +143 -0
  291. osn_selenium/executors/unified/cdp/cache_storage.py +69 -0
  292. osn_selenium/executors/unified/cdp/cast.py +32 -0
  293. osn_selenium/executors/unified/cdp/console.py +18 -0
  294. osn_selenium/executors/unified/cdp/css.py +237 -0
  295. osn_selenium/executors/unified/cdp/debugger.py +243 -0
  296. osn_selenium/executors/unified/cdp/device_access.py +21 -0
  297. osn_selenium/executors/unified/cdp/device_orientation.py +18 -0
  298. osn_selenium/executors/unified/cdp/dom.py +380 -0
  299. osn_selenium/executors/unified/cdp/dom_debugger.py +65 -0
  300. osn_selenium/executors/unified/cdp/dom_snapshot.py +58 -0
  301. osn_selenium/executors/unified/cdp/dom_storage.py +38 -0
  302. osn_selenium/executors/unified/cdp/emulation.py +312 -0
  303. osn_selenium/executors/unified/cdp/event_breakpoints.py +24 -0
  304. osn_selenium/executors/unified/cdp/extensions.py +45 -0
  305. osn_selenium/executors/unified/cdp/fed_cm.py +51 -0
  306. osn_selenium/executors/unified/cdp/fetch.py +111 -0
  307. osn_selenium/executors/unified/cdp/file_system.py +15 -0
  308. osn_selenium/executors/unified/cdp/headless_experimental.py +38 -0
  309. osn_selenium/executors/unified/cdp/heap_profiler.py +101 -0
  310. osn_selenium/executors/unified/cdp/indexed_db.py +157 -0
  311. osn_selenium/executors/unified/cdp/input.py +254 -0
  312. osn_selenium/executors/unified/cdp/inspector.py +15 -0
  313. osn_selenium/executors/unified/cdp/io.py +29 -0
  314. osn_selenium/executors/unified/cdp/layer_tree.py +71 -0
  315. osn_selenium/executors/unified/cdp/log.py +29 -0
  316. osn_selenium/executors/unified/cdp/media.py +15 -0
  317. osn_selenium/executors/unified/cdp/memory.py +59 -0
  318. osn_selenium/executors/unified/cdp/network.py +323 -0
  319. osn_selenium/executors/unified/cdp/overlay.py +209 -0
  320. osn_selenium/executors/unified/cdp/page.py +410 -0
  321. osn_selenium/executors/unified/cdp/performance.py +27 -0
  322. osn_selenium/executors/unified/cdp/performance_timeline.py +17 -0
  323. osn_selenium/executors/unified/cdp/preload.py +15 -0
  324. osn_selenium/executors/unified/cdp/profiler.py +55 -0
  325. osn_selenium/executors/unified/cdp/pwa.py +55 -0
  326. osn_selenium/executors/unified/cdp/runtime.py +245 -0
  327. osn_selenium/executors/unified/cdp/schema.py +17 -0
  328. osn_selenium/executors/unified/cdp/security.py +27 -0
  329. osn_selenium/executors/unified/cdp/service_worker.py +62 -0
  330. osn_selenium/executors/unified/cdp/storage.py +178 -0
  331. osn_selenium/executors/unified/cdp/system_info.py +24 -0
  332. osn_selenium/executors/unified/cdp/target.py +165 -0
  333. osn_selenium/executors/unified/cdp/tethering.py +15 -0
  334. osn_selenium/executors/unified/cdp/tracing.py +62 -0
  335. osn_selenium/executors/unified/cdp/web_audio.py +18 -0
  336. osn_selenium/executors/unified/cdp/web_authn.py +103 -0
  337. osn_selenium/executors/unified/javascript.py +108 -0
  338. osn_selenium/flags/__init__.py +1 -0
  339. osn_selenium/flags/_functions.py +45 -0
  340. osn_selenium/flags/_typehints.py +34 -0
  341. osn_selenium/flags/_validators.py +101 -0
  342. osn_selenium/{webdrivers/BaseDriver/flags.py → flags/base.py} +165 -243
  343. osn_selenium/{webdrivers/Blink/flags.py → flags/blink.py} +133 -371
  344. osn_selenium/flags/chrome.py +259 -0
  345. osn_selenium/flags/edge.py +259 -0
  346. osn_selenium/flags/models/__init__.py +1 -0
  347. osn_selenium/flags/models/base.py +130 -0
  348. osn_selenium/flags/models/blink.py +263 -0
  349. osn_selenium/{webdrivers/Chrome/flags.py → flags/models/chrome.py} +25 -75
  350. osn_selenium/{webdrivers/Edge/flags.py → flags/models/edge.py} +25 -75
  351. osn_selenium/flags/models/values.py +44 -0
  352. osn_selenium/{webdrivers/Yandex/flags.py → flags/models/yandex.py} +26 -76
  353. osn_selenium/flags/yandex.py +259 -0
  354. osn_selenium/instances/__init__.py +1 -0
  355. osn_selenium/instances/_functions.py +242 -0
  356. osn_selenium/instances/_typehints.py +148 -0
  357. osn_selenium/instances/_utils.py +143 -0
  358. osn_selenium/instances/convert.py +287 -0
  359. osn_selenium/instances/protocols.py +105 -0
  360. osn_selenium/instances/sync/__init__.py +1 -0
  361. osn_selenium/instances/sync/action_chains/__init__.py +26 -0
  362. osn_selenium/instances/sync/action_chains/base.py +74 -0
  363. osn_selenium/instances/sync/action_chains/click.py +61 -0
  364. osn_selenium/instances/sync/action_chains/drag_and_drop.py +45 -0
  365. osn_selenium/instances/sync/action_chains/hm_keyboard.py +37 -0
  366. osn_selenium/instances/sync/action_chains/hm_move.py +81 -0
  367. osn_selenium/instances/sync/action_chains/hm_scroll.py +60 -0
  368. osn_selenium/instances/sync/action_chains/keyboard.py +55 -0
  369. osn_selenium/instances/sync/action_chains/move.py +46 -0
  370. osn_selenium/instances/sync/action_chains/scroll.py +43 -0
  371. osn_selenium/instances/sync/action_chains/utils.py +30 -0
  372. osn_selenium/instances/sync/alert.py +69 -0
  373. osn_selenium/instances/sync/browser.py +72 -0
  374. osn_selenium/instances/sync/browsing_context.py +193 -0
  375. osn_selenium/instances/sync/dialog.py +81 -0
  376. osn_selenium/instances/sync/fedcm.py +92 -0
  377. osn_selenium/instances/sync/mobile.py +75 -0
  378. osn_selenium/instances/sync/network.py +90 -0
  379. osn_selenium/instances/sync/permissions.py +80 -0
  380. osn_selenium/instances/sync/script.py +77 -0
  381. osn_selenium/instances/sync/shadow_root.py +91 -0
  382. osn_selenium/instances/sync/storage.py +91 -0
  383. osn_selenium/instances/sync/switch_to.py +92 -0
  384. osn_selenium/instances/sync/web_driver_wait.py +83 -0
  385. osn_selenium/instances/sync/web_element.py +179 -0
  386. osn_selenium/instances/sync/web_extension.py +77 -0
  387. osn_selenium/instances/trio_threads/__init__.py +1 -0
  388. osn_selenium/instances/trio_threads/action_chains/__init__.py +26 -0
  389. osn_selenium/instances/trio_threads/action_chains/base.py +88 -0
  390. osn_selenium/instances/trio_threads/action_chains/click.py +71 -0
  391. osn_selenium/instances/trio_threads/action_chains/drag_and_drop.py +49 -0
  392. osn_selenium/instances/trio_threads/action_chains/hm_keyboard.py +41 -0
  393. osn_selenium/instances/trio_threads/action_chains/hm_move.py +91 -0
  394. osn_selenium/instances/trio_threads/action_chains/hm_scroll.py +66 -0
  395. osn_selenium/instances/trio_threads/action_chains/keyboard.py +63 -0
  396. osn_selenium/instances/trio_threads/action_chains/move.py +52 -0
  397. osn_selenium/instances/trio_threads/action_chains/scroll.py +49 -0
  398. osn_selenium/instances/trio_threads/action_chains/utils.py +32 -0
  399. osn_selenium/instances/trio_threads/alert.py +87 -0
  400. osn_selenium/instances/trio_threads/browser.py +90 -0
  401. osn_selenium/instances/trio_threads/browsing_context.py +216 -0
  402. osn_selenium/instances/trio_threads/dialog.py +99 -0
  403. osn_selenium/instances/trio_threads/fedcm.py +110 -0
  404. osn_selenium/instances/trio_threads/mobile.py +93 -0
  405. osn_selenium/instances/trio_threads/network.py +108 -0
  406. osn_selenium/instances/trio_threads/permissions.py +102 -0
  407. osn_selenium/instances/trio_threads/script.py +95 -0
  408. osn_selenium/instances/trio_threads/shadow_root.py +123 -0
  409. osn_selenium/instances/trio_threads/storage.py +109 -0
  410. osn_selenium/instances/trio_threads/switch_to.py +124 -0
  411. osn_selenium/instances/trio_threads/web_driver_wait.py +101 -0
  412. osn_selenium/instances/trio_threads/web_element.py +217 -0
  413. osn_selenium/instances/trio_threads/web_extension.py +99 -0
  414. osn_selenium/instances/unified/__init__.py +1 -0
  415. osn_selenium/instances/unified/action_chains/__init__.py +22 -0
  416. osn_selenium/instances/unified/action_chains/base.py +31 -0
  417. osn_selenium/instances/unified/action_chains/click.py +27 -0
  418. osn_selenium/instances/unified/action_chains/drag_and_drop.py +24 -0
  419. osn_selenium/instances/unified/action_chains/hm_keyboard.py +30 -0
  420. osn_selenium/instances/unified/action_chains/hm_move.py +66 -0
  421. osn_selenium/instances/unified/action_chains/hm_scroll.py +79 -0
  422. osn_selenium/instances/unified/action_chains/keyboard.py +24 -0
  423. osn_selenium/instances/unified/action_chains/move.py +24 -0
  424. osn_selenium/instances/unified/action_chains/scroll.py +21 -0
  425. osn_selenium/instances/unified/action_chains/utils.py +19 -0
  426. osn_selenium/instances/unified/alert.py +29 -0
  427. osn_selenium/instances/unified/browser.py +33 -0
  428. osn_selenium/instances/unified/browsing_context.py +151 -0
  429. osn_selenium/instances/unified/dialog.py +42 -0
  430. osn_selenium/instances/unified/fedcm.py +48 -0
  431. osn_selenium/instances/unified/mobile.py +36 -0
  432. osn_selenium/instances/unified/network.py +50 -0
  433. osn_selenium/instances/unified/permissions.py +43 -0
  434. osn_selenium/instances/unified/script.py +38 -0
  435. osn_selenium/instances/unified/shadow_root.py +46 -0
  436. osn_selenium/instances/unified/storage.py +48 -0
  437. osn_selenium/instances/unified/switch_to.py +49 -0
  438. osn_selenium/instances/unified/web_driver_wait.py +45 -0
  439. osn_selenium/instances/unified/web_element.py +145 -0
  440. osn_selenium/instances/unified/web_extension.py +38 -0
  441. osn_selenium/javascript/__init__.py +1 -0
  442. osn_selenium/javascript/_functions.py +63 -0
  443. osn_selenium/javascript/fingerprint/__init__.py +120 -0
  444. osn_selenium/javascript/fingerprint/_decorators.py +41 -0
  445. osn_selenium/javascript/fingerprint/_detect/__init__.py +1 -0
  446. osn_selenium/javascript/fingerprint/_detect/functions.py +253 -0
  447. osn_selenium/javascript/fingerprint/_detect/templates.py +128 -0
  448. osn_selenium/javascript/fingerprint/_functions.py +35 -0
  449. osn_selenium/javascript/fingerprint/_typehints.py +27 -0
  450. osn_selenium/javascript/fingerprint/registry/__init__.py +7 -0
  451. osn_selenium/javascript/fingerprint/registry/_core_functions.py +236 -0
  452. osn_selenium/javascript/fingerprint/registry/_functions.py +923 -0
  453. osn_selenium/javascript/fingerprint/registry/_typehints.py +6 -0
  454. osn_selenium/javascript/fingerprint/registry/_utils.py +6 -0
  455. osn_selenium/javascript/fingerprint/registry/models.py +41 -0
  456. osn_selenium/javascript/fingerprint/spoof/__init__.py +1 -0
  457. osn_selenium/javascript/fingerprint/spoof/_functions.py +172 -0
  458. osn_selenium/javascript/fingerprint/spoof/_templates.py +134 -0
  459. osn_selenium/javascript/fingerprint/spoof/_typehints.py +22 -0
  460. osn_selenium/javascript/fingerprint/spoof/core_rules.py +141 -0
  461. osn_selenium/javascript/fingerprint/spoof/noise.py +51 -0
  462. osn_selenium/javascript/fingerprint/spoof/rules.py +313 -0
  463. osn_selenium/javascript/functions.py +44 -0
  464. osn_selenium/javascript/models.py +35 -0
  465. osn_selenium/javascript/scripts/start_fingerprint_detection.js +56 -0
  466. osn_selenium/models.py +139 -0
  467. osn_selenium/webdrivers/_args_helpers.py +181 -0
  468. osn_selenium/webdrivers/_bridges.py +57 -0
  469. osn_selenium/webdrivers/_decorators.py +83 -0
  470. osn_selenium/webdrivers/_executable_tables/__init__.py +1 -0
  471. osn_selenium/webdrivers/_executable_tables/functions.py +113 -0
  472. osn_selenium/webdrivers/_executable_tables/models.py +19 -0
  473. osn_selenium/webdrivers/_typehints.py +10 -0
  474. osn_selenium/webdrivers/protocols.py +50 -0
  475. osn_selenium/webdrivers/sync/__init__.py +1 -0
  476. osn_selenium/webdrivers/sync/blink/__init__.py +114 -0
  477. osn_selenium/webdrivers/sync/blink/base.py +128 -0
  478. osn_selenium/webdrivers/sync/blink/casting.py +34 -0
  479. osn_selenium/webdrivers/sync/blink/features.py +28 -0
  480. osn_selenium/webdrivers/sync/blink/lifecycle.py +66 -0
  481. osn_selenium/webdrivers/sync/blink/logging.py +25 -0
  482. osn_selenium/webdrivers/sync/blink/network.py +28 -0
  483. osn_selenium/webdrivers/sync/blink/settings.py +63 -0
  484. osn_selenium/webdrivers/sync/chrome/__init__.py +67 -0
  485. osn_selenium/webdrivers/sync/chrome/base.py +106 -0
  486. osn_selenium/webdrivers/sync/chrome/lifecycle.py +63 -0
  487. osn_selenium/webdrivers/sync/chrome/settings.py +58 -0
  488. osn_selenium/webdrivers/sync/core/__init__.py +91 -0
  489. osn_selenium/webdrivers/sync/core/actions.py +59 -0
  490. osn_selenium/webdrivers/sync/core/auth.py +77 -0
  491. osn_selenium/webdrivers/sync/core/base.py +167 -0
  492. osn_selenium/webdrivers/sync/core/capture.py +37 -0
  493. osn_selenium/webdrivers/sync/core/comonents.py +57 -0
  494. osn_selenium/webdrivers/sync/core/devtools.py +47 -0
  495. osn_selenium/webdrivers/sync/core/element.py +42 -0
  496. osn_selenium/webdrivers/sync/core/file.py +40 -0
  497. osn_selenium/webdrivers/sync/core/lifecycle.py +59 -0
  498. osn_selenium/webdrivers/sync/core/navigation.py +36 -0
  499. osn_selenium/webdrivers/sync/core/script.py +53 -0
  500. osn_selenium/webdrivers/sync/core/settings.py +35 -0
  501. osn_selenium/webdrivers/sync/core/storage.py +48 -0
  502. osn_selenium/webdrivers/sync/core/timeouts.py +59 -0
  503. osn_selenium/webdrivers/sync/core/window.py +99 -0
  504. osn_selenium/webdrivers/sync/edge/__init__.py +67 -0
  505. osn_selenium/webdrivers/sync/edge/base.py +102 -0
  506. osn_selenium/webdrivers/sync/edge/lifecycle.py +63 -0
  507. osn_selenium/webdrivers/sync/edge/settings.py +58 -0
  508. osn_selenium/webdrivers/sync/yandex/__init__.py +67 -0
  509. osn_selenium/webdrivers/sync/yandex/base.py +99 -0
  510. osn_selenium/webdrivers/sync/yandex/lifecycle.py +63 -0
  511. osn_selenium/webdrivers/sync/yandex/settings.py +58 -0
  512. osn_selenium/webdrivers/trio_threads/__init__.py +1 -0
  513. osn_selenium/webdrivers/trio_threads/blink/__init__.py +124 -0
  514. osn_selenium/webdrivers/trio_threads/blink/base.py +133 -0
  515. osn_selenium/webdrivers/trio_threads/blink/casting.py +35 -0
  516. osn_selenium/webdrivers/trio_threads/blink/features.py +29 -0
  517. osn_selenium/webdrivers/trio_threads/blink/lifecycle.py +66 -0
  518. osn_selenium/webdrivers/trio_threads/blink/logging.py +26 -0
  519. osn_selenium/webdrivers/trio_threads/blink/network.py +29 -0
  520. osn_selenium/webdrivers/trio_threads/blink/settings.py +63 -0
  521. osn_selenium/webdrivers/trio_threads/chrome/__init__.py +81 -0
  522. osn_selenium/webdrivers/trio_threads/chrome/base.py +107 -0
  523. osn_selenium/webdrivers/trio_threads/chrome/lifecycle.py +63 -0
  524. osn_selenium/webdrivers/trio_threads/chrome/settings.py +63 -0
  525. osn_selenium/webdrivers/trio_threads/core/__init__.py +109 -0
  526. osn_selenium/webdrivers/trio_threads/core/actions.py +72 -0
  527. osn_selenium/webdrivers/trio_threads/core/auth.py +88 -0
  528. osn_selenium/webdrivers/trio_threads/core/base.py +191 -0
  529. osn_selenium/webdrivers/trio_threads/core/capture.py +38 -0
  530. osn_selenium/webdrivers/trio_threads/core/comonents.py +92 -0
  531. osn_selenium/webdrivers/trio_threads/core/devtools.py +53 -0
  532. osn_selenium/webdrivers/trio_threads/core/element.py +58 -0
  533. osn_selenium/webdrivers/trio_threads/core/file.py +45 -0
  534. osn_selenium/webdrivers/trio_threads/core/lifecycle.py +60 -0
  535. osn_selenium/webdrivers/trio_threads/core/navigation.py +41 -0
  536. osn_selenium/webdrivers/trio_threads/core/script.py +59 -0
  537. osn_selenium/webdrivers/trio_threads/core/settings.py +36 -0
  538. osn_selenium/webdrivers/trio_threads/core/storage.py +54 -0
  539. osn_selenium/webdrivers/trio_threads/core/timeouts.py +60 -0
  540. osn_selenium/webdrivers/trio_threads/core/window.py +105 -0
  541. osn_selenium/webdrivers/trio_threads/edge/__init__.py +81 -0
  542. osn_selenium/webdrivers/trio_threads/edge/base.py +103 -0
  543. osn_selenium/webdrivers/trio_threads/edge/lifecycle.py +63 -0
  544. osn_selenium/webdrivers/trio_threads/edge/settings.py +63 -0
  545. osn_selenium/webdrivers/trio_threads/yandex/__init__.py +81 -0
  546. osn_selenium/webdrivers/trio_threads/yandex/base.py +100 -0
  547. osn_selenium/webdrivers/trio_threads/yandex/lifecycle.py +63 -0
  548. osn_selenium/webdrivers/trio_threads/yandex/settings.py +63 -0
  549. osn_selenium/webdrivers/unified/__init__.py +1 -0
  550. osn_selenium/webdrivers/unified/blink/__init__.py +1 -0
  551. osn_selenium/webdrivers/unified/blink/base.py +131 -0
  552. osn_selenium/webdrivers/unified/blink/casting.py +30 -0
  553. osn_selenium/webdrivers/unified/blink/features.py +22 -0
  554. osn_selenium/webdrivers/unified/blink/lifecycle.py +114 -0
  555. osn_selenium/webdrivers/unified/blink/logging.py +18 -0
  556. osn_selenium/webdrivers/unified/blink/network.py +22 -0
  557. osn_selenium/webdrivers/unified/blink/settings.py +86 -0
  558. osn_selenium/webdrivers/unified/chrome/__init__.py +1 -0
  559. osn_selenium/webdrivers/unified/chrome/base.py +54 -0
  560. osn_selenium/webdrivers/unified/chrome/lifecycle.py +88 -0
  561. osn_selenium/webdrivers/unified/chrome/settings.py +48 -0
  562. osn_selenium/webdrivers/unified/core/__init__.py +1 -0
  563. osn_selenium/webdrivers/unified/core/actions.py +43 -0
  564. osn_selenium/webdrivers/unified/core/auth.py +70 -0
  565. osn_selenium/webdrivers/unified/core/base.py +132 -0
  566. osn_selenium/webdrivers/unified/core/capture.py +32 -0
  567. osn_selenium/webdrivers/unified/core/components.py +32 -0
  568. osn_selenium/webdrivers/unified/core/devtools.py +35 -0
  569. osn_selenium/webdrivers/unified/core/element.py +24 -0
  570. osn_selenium/webdrivers/unified/core/file.py +35 -0
  571. osn_selenium/webdrivers/unified/core/lifecycle.py +84 -0
  572. osn_selenium/webdrivers/unified/core/navigation.py +31 -0
  573. osn_selenium/webdrivers/unified/core/script.py +32 -0
  574. osn_selenium/webdrivers/unified/core/settings.py +44 -0
  575. osn_selenium/webdrivers/unified/core/storage.py +37 -0
  576. osn_selenium/webdrivers/unified/core/timeouts.py +56 -0
  577. osn_selenium/webdrivers/unified/core/window.py +135 -0
  578. osn_selenium/webdrivers/unified/edge/__init__.py +1 -0
  579. osn_selenium/webdrivers/unified/edge/base.py +52 -0
  580. osn_selenium/webdrivers/unified/edge/lifecycle.py +88 -0
  581. osn_selenium/webdrivers/unified/edge/settings.py +48 -0
  582. osn_selenium/webdrivers/unified/yandex/__init__.py +1 -0
  583. osn_selenium/webdrivers/unified/yandex/base.py +54 -0
  584. osn_selenium/webdrivers/unified/yandex/lifecycle.py +58 -0
  585. osn_selenium/webdrivers/unified/yandex/settings.py +48 -0
  586. osn_selenium-1.0.0.dist-info/METADATA +239 -0
  587. osn_selenium-1.0.0.dist-info/RECORD +608 -0
  588. {osn_selenium-0.0.0.dist-info → osn_selenium-1.0.0.dist-info}/WHEEL +1 -1
  589. osn_selenium/captcha_workers/__init__.py +0 -26
  590. osn_selenium/dev_tools/_types.py +0 -22
  591. osn_selenium/dev_tools/errors.py +0 -89
  592. osn_selenium/dev_tools/logger.py +0 -558
  593. osn_selenium/dev_tools/manager.py +0 -1551
  594. osn_selenium/dev_tools/utils.py +0 -509
  595. osn_selenium/errors.py +0 -16
  596. osn_selenium/types.py +0 -118
  597. osn_selenium/webdrivers/BaseDriver/_utils.py +0 -37
  598. osn_selenium/webdrivers/BaseDriver/protocols.py +0 -2135
  599. osn_selenium/webdrivers/BaseDriver/trio_wrapper.py +0 -71
  600. osn_selenium/webdrivers/BaseDriver/webdriver.py +0 -2626
  601. osn_selenium/webdrivers/Blink/protocols.py +0 -330
  602. osn_selenium/webdrivers/Blink/webdriver.py +0 -637
  603. osn_selenium/webdrivers/Chrome/protocols.py +0 -228
  604. osn_selenium/webdrivers/Chrome/webdriver.py +0 -394
  605. osn_selenium/webdrivers/Edge/protocols.py +0 -228
  606. osn_selenium/webdrivers/Edge/webdriver.py +0 -394
  607. osn_selenium/webdrivers/Yandex/protocols.py +0 -211
  608. osn_selenium/webdrivers/Yandex/webdriver.py +0 -350
  609. osn_selenium/webdrivers/_functions.py +0 -504
  610. osn_selenium/webdrivers/types.py +0 -390
  611. osn_selenium-0.0.0.dist-info/METADATA +0 -710
  612. osn_selenium-0.0.0.dist-info/RECORD +0 -57
  613. /osn_selenium/{webdrivers/BaseDriver → abstract}/__init__.py +0 -0
  614. /osn_selenium/{webdrivers/Blink → abstract/executors}/__init__.py +0 -0
  615. /osn_selenium/{webdrivers/Chrome → abstract/instances}/__init__.py +0 -0
  616. /osn_selenium/{webdrivers/Edge → abstract/webdriver}/__init__.py +0 -0
  617. /osn_selenium/{webdrivers/Yandex → dev_tools/logger}/__init__.py +0 -0
  618. /osn_selenium/{webdrivers/js_scripts → javascript/scripts}/check_element_in_viewport.js +0 -0
  619. /osn_selenium/{webdrivers/js_scripts → javascript/scripts}/get_document_scroll_size.js +0 -0
  620. /osn_selenium/{webdrivers/js_scripts → javascript/scripts}/get_element_css.js +0 -0
  621. /osn_selenium/{webdrivers/js_scripts → javascript/scripts}/get_element_rect_in_viewport.js +0 -0
  622. /osn_selenium/{webdrivers/js_scripts → javascript/scripts}/get_random_element_point_in_viewport.js +0 -0
  623. /osn_selenium/{webdrivers/js_scripts → javascript/scripts}/get_viewport_position.js +0 -0
  624. /osn_selenium/{webdrivers/js_scripts → javascript/scripts}/get_viewport_rect.js +0 -0
  625. /osn_selenium/{webdrivers/js_scripts → javascript/scripts}/get_viewport_size.js +0 -0
  626. /osn_selenium/{webdrivers/js_scripts → javascript/scripts}/open_new_tab.js +0 -0
  627. /osn_selenium/{webdrivers/js_scripts → javascript/scripts}/stop_window_loading.js +0 -0
  628. {osn_selenium-0.0.0.dist-info → osn_selenium-1.0.0.dist-info}/top_level.txt +0 -0
@@ -1,2135 +0,0 @@
1
- import trio
2
- import pathlib
3
- from selenium import webdriver
4
- from selenium.webdriver import ActionChains
5
- from selenium.webdriver.remote.fedcm import FedCM
6
- from selenium.webdriver.common.fedcm.dialog import Dialog
7
- from selenium.webdriver.remote.webelement import WebElement
8
- from selenium.webdriver.common.actions.key_input import KeyInput
9
- from selenium.webdriver.common.print_page_options import PrintOptions
10
- from selenium.webdriver.remote.remote_connection import RemoteConnection
11
- from selenium.webdriver.common.actions.pointer_input import PointerInput
12
- from osn_selenium.types import (
13
- Position,
14
- Rectangle,
15
- Size,
16
- WindowRect
17
- )
18
- from selenium.webdriver.common.actions.wheel_input import (
19
- ScrollOrigin,
20
- WheelInput
21
- )
22
- from osn_selenium.webdrivers.types import (
23
- ActionPoint,
24
- JS_Scripts,
25
- _any_flags_mapping
26
- )
27
- from typing import (
28
- Any,
29
- Literal,
30
- Optional,
31
- Protocol,
32
- TYPE_CHECKING,
33
- Union,
34
- runtime_checkable
35
- )
36
- from selenium.webdriver.common.virtual_authenticator import (
37
- Credential,
38
- VirtualAuthenticatorOptions
39
- )
40
-
41
-
42
- if TYPE_CHECKING:
43
- from osn_selenium.dev_tools.manager import DevTools
44
- from osn_selenium.webdrivers.BaseDriver.flags import BrowserFlags, BrowserFlagsManager
45
- from osn_selenium.webdrivers.BaseDriver.webdriver import BrowserWebDriver, CaptchaWorkerSettings
46
-
47
-
48
- @runtime_checkable
49
- class TrioWebDriverWrapperProtocol(Protocol):
50
- """
51
- Wraps BrowserWebDriver methods for asynchronous execution using Trio.
52
-
53
- This class acts as a proxy to a `BrowserWebDriver` instance. It intercepts
54
- method calls and executes them in a separate thread using `trio.to_thread.run_sync`,
55
- allowing synchronous WebDriver operations to be called from asynchronous Trio code
56
- without blocking the event loop. Properties and non-callable attributes are accessed directly.
57
-
58
- Attributes:
59
- _webdriver (BrowserWebDriver): The underlying synchronous BrowserWebDriver instance.
60
- _excluding_functions (list[str]): A list of attribute names on the wrapped object
61
- that should *not* be accessible through this wrapper,
62
- typically because they are irrelevant or dangerous
63
- in an async context handled by the wrapper.
64
- """
65
-
66
- _webdriver: "BrowserWebDriver"
67
- _excluding_functions: list[str]
68
- window_rect: Optional[WindowRect]
69
- _js_scripts: JS_Scripts
70
- _webdriver_path: str
71
- _webdriver_flags_manager: "BrowserFlagsManager"
72
- _driver: Optional[Union[webdriver.Chrome, webdriver.Edge, webdriver.Firefox]]
73
- _base_implicitly_wait: int
74
- _base_page_load_timeout: int
75
- _base_script_timeout: int
76
- _captcha_workers: list["CaptchaWorkerSettings"]
77
- _is_active: bool
78
- trio_capacity_limiter: trio.CapacityLimiter
79
- dev_tools: "DevTools"
80
-
81
- async def add_captcha_worker(self, captcha_worker: "CaptchaWorkerSettings"):
82
- """
83
- Adds a new captcha worker to the list of active captcha workers.
84
-
85
- Args:
86
- captcha_worker ("CaptchaWorkerSettings"): A dictionary containing the name,
87
- check function, and solve function for the captcha worker.
88
- """
89
-
90
- ...
91
-
92
- async def add_cookie(self, cookie_dict: dict[str, Any]):
93
- """
94
- Adds a single cookie to the current browser session.
95
-
96
- Args:
97
- cookie_dict (dict[str, Any]): A dictionary representing the cookie to add.
98
- """
99
-
100
- ...
101
-
102
- async def add_credential(self, credential: Credential):
103
- """
104
- Adds a WebAuthn credential to the browser's virtual authenticator.
105
-
106
- Args:
107
- credential (Credential): The `Credential` object representing the WebAuthn credential.
108
- """
109
-
110
- ...
111
-
112
- async def add_virtual_authenticator(self, options: VirtualAuthenticatorOptions):
113
- """
114
- Adds a virtual authenticator to the browser for WebAuthn testing.
115
-
116
- Args:
117
- options (VirtualAuthenticatorOptions): The `VirtualAuthenticatorOptions` object
118
- specifying the properties of the virtual authenticator.
119
- """
120
-
121
- ...
122
-
123
- async def build_action_chains(
124
- self,
125
- duration: int = 250,
126
- devices: Optional[list[Union[PointerInput, KeyInput, WheelInput]]] = None
127
- ) -> ActionChains:
128
- """
129
- Builds and returns a new Selenium ActionChains instance.
130
-
131
- Initializes an ActionChains object associated with the current WebDriver instance (`self.driver`).
132
- Allows specifying the default pause duration between actions and custom input device sources.
133
-
134
- Args:
135
- duration (int): The default duration in milliseconds to pause between actions
136
- within the chain. Defaults to 250.
137
- devices (Optional[list[Union[PointerInput, KeyInput, WheelInput]]]): A list of
138
- specific input device sources (Pointer, Key, Wheel) to use for the actions.
139
- If None, default devices are used. Defaults to None.
140
-
141
- Returns:
142
- ActionChains: A new ActionChains instance configured with the specified driver,
143
- duration, and devices.
144
- """
145
-
146
- ...
147
-
148
- async def build_hm_move_action(
149
- self,
150
- start_position: ActionPoint,
151
- end_position: ActionPoint,
152
- parent_action: Optional[ActionChains] = None,
153
- duration: int = 250,
154
- devices: Optional[list[Union[PointerInput, KeyInput, WheelInput]]] = None
155
- ) -> ActionChains:
156
- """
157
- Builds a human-like mouse move action sequence between two points.
158
-
159
- Simulates a more natural mouse movement by breaking the path into smaller segments with pauses,
160
- calculated by the external `move_to_parts` function. Adds the corresponding move-by-offset
161
- actions and pauses to an ActionChains sequence. Assumes the starting point of the cursor
162
- is implicitly handled or should be set prior to performing this chain.
163
-
164
- Args:
165
- start_position (ActionPoint): The starting coordinates (absolute or relative, depends on `move_to_parts` logic).
166
- end_position (ActionPoint): The target coordinates for the mouse cursor.
167
- parent_action (Optional[ActionChains]): An existing ActionChains instance to append actions to.
168
- If None, a new chain is created. Defaults to None.
169
- duration (int): The base duration (in milliseconds) used when creating a new ActionChains
170
- instance if `parent_action` is None. Total move time depends on `move_to_parts`. Defaults to 250.
171
- devices (Optional[list[Union[PointerInput, KeyInput, WheelInput]]]): Specific input devices
172
- if creating a new ActionChains instance. Defaults to None.
173
-
174
- Returns:
175
- ActionChains: The ActionChains instance (new or parent) with the human-like move sequence added.
176
- Needs to be finalized with `.perform()`.
177
- """
178
-
179
- ...
180
-
181
- async def build_hm_move_to_element_action(
182
- self,
183
- start_position: ActionPoint,
184
- element: WebElement,
185
- parent_action: Optional[ActionChains] = None,
186
- duration: int = 250,
187
- devices: Optional[list[Union[PointerInput, KeyInput, WheelInput]]] = None
188
- ) -> tuple[ActionChains, ActionPoint]:
189
- """
190
- Builds a human-like mouse move action from a start point to a random point within a target element.
191
-
192
- Determines a random target point within the element's boundary relative to the viewport
193
- (using `get_random_element_point`) and then uses `build_hm_move_action` to create
194
- a human-like movement sequence to that point. Returns both the action chain and the
195
- calculated end point.
196
-
197
- Args:
198
- start_position (ActionPoint): The starting coordinates (relative to viewport) for the mouse movement.
199
- element (WebElement): The target element to move the mouse into.
200
- parent_action (Optional[ActionChains]): An existing ActionChains instance to append actions to.
201
- If None, a new chain is created. Defaults to None.
202
- duration (int): Base duration (in milliseconds) used when creating a new ActionChains
203
- instance if `parent_action` is None. Total move time depends on the
204
- `move_to_parts` calculation within `build_hm_move_action`. Defaults to 250.
205
- devices (Optional[list[Union[PointerInput, KeyInput, WheelInput]]]): Specific input devices
206
- to use if creating a new ActionChains
207
- instance. Defaults to None.
208
-
209
- Returns:
210
- Tuple[ActionChains, ActionPoint]: A tuple containing:
211
-
212
- - The ActionChains instance with the human-like move-to-element sequence added.
213
- Needs to be finalized with `.perform()`.
214
- - The calculated end `ActionPoint` (relative to viewport) within the element that the
215
- mouse path targets.
216
- """
217
-
218
- ...
219
-
220
- async def build_hm_scroll_action(
221
- self,
222
- delta_x: int,
223
- delta_y: int,
224
- origin: Optional[ScrollOrigin] = None,
225
- parent_action: Optional[ActionChains] = None,
226
- duration: int = 250,
227
- devices: Optional[list[Union[PointerInput, KeyInput, WheelInput]]] = None
228
- ) -> ActionChains:
229
- """
230
- Builds a human-like scroll action sequence by breaking the scroll into smaller parts with pauses.
231
-
232
- This method simulates a more natural scroll compared to a direct jump. It calculates scroll segments
233
- using an external `scroll_to_parts` function and adds corresponding scroll actions and pauses
234
- to an ActionChains sequence. If no origin is provided, it defaults to scrolling from the
235
- bottom-right corner for positive deltas and top-left for negative deltas of the viewport.
236
-
237
- Args:
238
- delta_x (int): The total horizontal distance to scroll. Positive scrolls right, negative scrolls left.
239
- delta_y (int): The total vertical distance to scroll. Positive scrolls down, negative scrolls up.
240
- origin (Optional[ScrollOrigin]): The origin point for the scroll (viewport or element center).
241
- If None, defaults to a viewport corner based on scroll direction. Defaults to None.
242
- parent_action (Optional[ActionChains]): An existing ActionChains instance to append actions to.
243
- If None, a new chain is created. Defaults to None.
244
- duration (int): The base duration (in milliseconds) used when creating a new ActionChains
245
- instance if `parent_action` is None. This duration is *not* directly the total scroll time,
246
- which is determined by the sum of pauses from `scroll_to_parts`. Defaults to 250.
247
- devices (Optional[list[Union[PointerInput, KeyInput, WheelInput]]]): Specific input devices
248
- to use if creating a new ActionChains instance. Defaults to None.
249
-
250
- Returns:
251
- ActionChains: The ActionChains instance (new or parent) with the human-like scroll sequence added.
252
- Needs to be finalized with `.perform()`.
253
- """
254
-
255
- ...
256
-
257
- async def build_hm_scroll_to_element_action(
258
- self,
259
- element: WebElement,
260
- additional_lower_y_offset: int = 0,
261
- additional_upper_y_offset: int = 0,
262
- additional_right_x_offset: int = 0,
263
- additional_left_x_offset: int = 0,
264
- origin: Optional[ScrollOrigin] = None,
265
- parent_action: Optional[ActionChains] = None,
266
- duration: int = 250,
267
- devices: Optional[list[Union[PointerInput, KeyInput, WheelInput]]] = None
268
- ) -> ActionChains:
269
- """
270
- Builds a human-like scroll action to bring an element into view with optional offsets.
271
-
272
- Calculates the necessary scroll delta (dx, dy) to make the target element visible within the
273
- viewport, considering additional offset margins. It then uses `build_hm_scroll_action`
274
- to perform the scroll in a human-like manner.
275
-
276
- Args:
277
- element (WebElement): The target element to scroll into view.
278
- additional_lower_y_offset (int): Extra space (in pixels) to leave below the element within the viewport. Defaults to 0.
279
- additional_upper_y_offset (int): Extra space (in pixels) to leave above the element within the viewport. Defaults to 0.
280
- additional_right_x_offset (int): Extra space (in pixels) to leave to the right of the element within the viewport. Defaults to 0.
281
- additional_left_x_offset (int): Extra space (in pixels) to leave to the left of the element within the viewport. Defaults to 0.
282
- origin (Optional[ScrollOrigin]): The origin point for the scroll. Passed to `build_hm_scroll_action`. Defaults to None.
283
- parent_action (Optional[ActionChains]): An existing ActionChains instance. Passed to `build_hm_scroll_action`. Defaults to None.
284
- duration (int): Base duration for creating a new ActionChains instance. Passed to `build_hm_scroll_action`. Defaults to 250.
285
- devices (Optional[list[Union[PointerInput, KeyInput, WheelInput]]]): Specific input devices. Passed to `build_hm_scroll_action`. Defaults to None.
286
-
287
- Returns:
288
- ActionChains: The ActionChains instance containing the human-like scroll-to-element sequence.
289
- Needs to be finalized with `.perform()`.
290
- """
291
-
292
- ...
293
-
294
- async def build_hm_text_input_action(
295
- self,
296
- text: str,
297
- parent_action: Optional[ActionChains] = None,
298
- duration: int = 250,
299
- devices: Optional[list[Union[PointerInput, KeyInput, WheelInput]]] = None
300
- ) -> ActionChains:
301
- """
302
- Builds a human-like text input action sequence.
303
-
304
- Simulates typing by breaking the input text into smaller chunks with pauses between them,
305
- calculated by the external `text_input_to_parts` function. Adds the corresponding
306
- send_keys actions and pauses to an ActionChains sequence.
307
-
308
- Args:
309
- text (str): The text string to be typed.
310
- parent_action (Optional[ActionChains]): An existing ActionChains instance to append actions to.
311
- If None, a new chain is created. Defaults to None.
312
- duration (int): The base duration (in milliseconds) used when creating a new ActionChains
313
- instance if `parent_action` is None. Total input time depends on `text_input_to_parts`. Defaults to 250.
314
- devices (Optional[list[Union[PointerInput, KeyInput, WheelInput]]]): Specific input devices
315
- if creating a new ActionChains instance. Defaults to None.
316
-
317
- Returns:
318
- ActionChains: The ActionChains instance (new or parent) with the human-like text input sequence added.
319
- Needs to be finalized with `.perform()`. Requires the target input element to have focus.
320
- """
321
-
322
- ...
323
-
324
- @property
325
- def captcha_workers(self) -> list["CaptchaWorkerSettings"]:
326
- """
327
- Gets the current list of configured captcha workers.
328
-
329
- Returns:
330
- list["CaptchaWorkerSettings"]: A list containing the current captcha worker settings.
331
- """
332
-
333
- ...
334
-
335
- async def check_captcha(self, check_all: bool = False) -> list[str]:
336
- """
337
- Iterates through registered captcha workers to detect and solve captchas.
338
-
339
- For each registered captcha worker, it calls a `check_func` to determine
340
- if a captcha is present. If found, it then calls the associated `solve_func`
341
- to attempt to solve it and records the name of the solved captcha.
342
- The process stops after the first solved captcha unless `check_all` is True.
343
-
344
- Args:
345
- check_all (bool): If True, all registered captcha workers will be checked
346
- and solved if present. If False, the method stops after the first
347
- captcha is successfully detected and solved. Defaults to False.
348
-
349
- Returns:
350
- list[str]: A list of names of the captchas that were detected and for which
351
- the `solve_func` was executed. The list will contain at most one element
352
- if `check_all` is False.
353
- """
354
-
355
- ...
356
-
357
- async def check_element_in_viewport(self, element: WebElement) -> bool:
358
- """
359
- Checks if the specified web element is currently within the browser's viewport.
360
-
361
- Executes a predefined JavaScript snippet to determine the visibility status.
362
-
363
- Args:
364
- element (WebElement): The Selenium WebElement to check.
365
-
366
- Returns:
367
- bool: True if the element is at least partially within the viewport, False otherwise.
368
- """
369
-
370
- ...
371
-
372
- async def click_action(
373
- self,
374
- element: Optional[WebElement] = None,
375
- duration: int = 250,
376
- action_chain: Optional[ActionChains] = None
377
- ) -> ActionChains:
378
- """
379
- Adds a click action. Clicks on the specified element or the current mouse position if no element is provided.
380
-
381
- If an existing ActionChains object is provided via `action_chain`, this action
382
- is appended to it. Otherwise, a new ActionChains object is created using
383
- `self.build_action_chains` with the specified duration before adding the action.
384
-
385
- Args:
386
- element (Optional[WebElement]): The web element to click. If None, clicks at the
387
- current mouse cursor position. Defaults to None.
388
- duration (int): The duration in milliseconds to use when creating a new
389
- ActionChains instance if `action_chain` is None. Defaults to 250.
390
- action_chain (Optional[ActionChains]): An existing ActionChains instance to append
391
- this action to. If None, a new chain is created. Defaults to None.
392
-
393
- Returns:
394
- ActionChains: The ActionChains instance (either the one passed in or a new one)
395
- with the click action added, allowing for method chaining.
396
- """
397
-
398
- ...
399
-
400
- async def click_and_hold_action(
401
- self,
402
- element: Optional[WebElement] = None,
403
- duration: int = 250,
404
- action_chain: Optional[ActionChains] = None
405
- ) -> ActionChains:
406
- """
407
- Adds a click-and-hold action. Holds down the left mouse button on the specified element or the current mouse position.
408
-
409
- If an existing ActionChains object is provided via `action_chain`, this action
410
- is appended to it. Otherwise, a new ActionChains object is created using
411
- `self.build_action_chains` with the specified duration before adding the action.
412
-
413
- Args:
414
- element (Optional[WebElement]): The web element to click and hold. If None, clicks
415
- and holds at the current mouse cursor position. Defaults to None.
416
- duration (int): The duration in milliseconds to use when creating a new
417
- ActionChains instance if `action_chain` is None. Defaults to 250.
418
- action_chain (Optional[ActionChains]): An existing ActionChains instance to append
419
- this action to. If None, a new chain is created. Defaults to None.
420
-
421
- Returns:
422
- ActionChains: The ActionChains instance (either the one passed in or a new one)
423
- with the click-and-hold action added, allowing for method chaining.
424
- """
425
-
426
- ...
427
-
428
- async def close_all_windows(self):
429
- """
430
- Closes all open windows.
431
-
432
- Iterates through all window handles and closes each window associated with the WebDriver instance.
433
- This effectively closes the entire browser session managed by the driver.
434
- """
435
-
436
- ...
437
-
438
- async def close_webdriver(self):
439
- """
440
- Closes the WebDriver instance and terminates the associated browser subprocess.
441
-
442
- Quits the current WebDriver session, closes all browser windows, and then forcefully terminates
443
- the browser process. This ensures a clean shutdown of the browser and WebDriver environment.
444
- """
445
-
446
- ...
447
-
448
- async def close_window(self, window: Optional[Union[str, int]] = None):
449
- """
450
- Closes the specified browser window and manages focus switching.
451
-
452
- Identifies the target window to close using get_window_handle. Switches to that window,
453
- closes it, and then switches focus back. If the closed window was the currently focused
454
- window, it switches focus to the last window in the remaining list. Otherwise, it switches
455
- back to the window that had focus before the close operation began.
456
-
457
- Args:
458
- window (Optional[Union[str, int]]): The identifier of the window to close.
459
- Can be a window handle (string), an index (int), or None to close the
460
- currently focused window.
461
- """
462
-
463
- ...
464
-
465
- async def cmd_activate_target(self, target_id: str,):
466
- """
467
- Activates a specific browser target, bringing it to the foreground.
468
-
469
- This command makes the specified target (tab or window) the active one,
470
- similar to clicking on a tab in a browser.
471
-
472
- Args:
473
- target_id (str): The unique ID of the target to activate.
474
- """
475
-
476
- ...
477
-
478
- async def cmd_attach_to_browser_target(self) -> str:
479
- """
480
- Attaches the DevTools session to the browser itself, not a specific tab or page.
481
-
482
- This allows for control over browser-wide features, such as managing browser contexts,
483
- extensions, or global network settings.
484
-
485
- Returns:
486
- str: The `sessionId` of the newly created DevTools session for the browser.
487
- """
488
-
489
- ...
490
-
491
- async def cmd_attach_to_target(self, target_id: str, flatten: Optional[bool] = None,) -> str:
492
- """
493
- Attaches the DevTools session to a specific browser target.
494
-
495
- Attaching allows you to send CDP commands and receive events for that specific target.
496
- This is typically done to control a specific tab or iframe.
497
-
498
- Args:
499
- target_id (str): The unique ID of the target to attach to.
500
- flatten (Optional[bool]): If True, all child targets (e.g., iframes within a page)
501
- will also be automatically attached. Defaults to False.
502
-
503
- Returns:
504
- str: The `sessionId` of the newly created DevTools session for this target.
505
- This session ID is used in subsequent CDP commands to specify which session
506
- the command applies to.
507
- """
508
-
509
- ...
510
-
511
- async def cmd_close_target(self, target_id: str,) -> bool:
512
- """
513
- Closes a specific browser target (tab or window).
514
-
515
- Args:
516
- target_id (str): The unique ID of the target to close.
517
-
518
- Returns:
519
- bool: True if the target was successfully closed, False otherwise.
520
- """
521
-
522
- ...
523
-
524
- async def cmd_create_browser_context(
525
- self,
526
- dispose_on_detach: Optional[bool] = None,
527
- proxy_server: Optional[str] = None,
528
- proxy_bypass_list: Optional[str] = None,
529
- origins_with_universal_network_access: Optional[list[str]] = None,
530
- ) -> str:
531
- """
532
- Sends a Chrome DevTools Protocol (CDP) command to create a new browser context.
533
-
534
- A browser context is an isolated environment, similar to an incognito window,
535
- where cookies, local storage, and other browser data are separate from
536
- the default context.
537
-
538
- Args:
539
- dispose_on_detach (Optional[bool]): If True, the browser context will be
540
- disposed of when the last target in it is detached.
541
- proxy_server (Optional[str]): Proxy server to use for the browser context
542
- (e.g., "http://localhost:8080").
543
- proxy_bypass_list (Optional[str]): Comma-separated list of hosts or IP addresses
544
- for which proxying should be bypassed.
545
- origins_with_universal_network_access (Optional[Sequence[str]]): A list of
546
- origins that are allowed to make network requests to any origin.
547
-
548
- Returns:
549
- str: The `browserContextId` of the newly created browser context.
550
- """
551
-
552
- ...
553
-
554
- async def cmd_create_target(
555
- self,
556
- url: str = "",
557
- left: Optional[int] = None,
558
- top: Optional[int] = None,
559
- width: Optional[int] = None,
560
- height: Optional[int] = None,
561
- window_state: Optional[Literal["normal", "minimized", "maximized", "fullscreen"]] = None,
562
- browser_context_id: Optional[str] = None,
563
- enable_begin_frame_control: Optional[bool] = None,
564
- new_window: Optional[bool] = None,
565
- background: Optional[bool] = None,
566
- for_tab: Optional[bool] = None,
567
- hidden: Optional[bool] = None,
568
- ) -> str:
569
- """
570
- Sends a Chrome DevTools Protocol (CDP) command to create a new browser target (tab or window).
571
-
572
- This method wraps the `Target.createTarget` CDP command, allowing for the creation
573
- of new browsing contexts with various configurations such as URL, dimensions,
574
- window state, and association with a specific browser context.
575
-
576
- Args:
577
- url (str): The URL to open in the new target. Defaults to an empty string,
578
- which typically opens a blank page.
579
- left (Optional[int]): The x-coordinate (left edge) of the new window/tab.
580
- Only applicable if `new_window` is True.
581
- top (Optional[int]): The y-coordinate (top edge) of the new window/tab.
582
- Only applicable if `new_window` is True.
583
- width (Optional[int]): The width of the new window/tab in pixels.
584
- Only applicable if `new_window` is True.
585
- height (Optional[int]): The height of the new window/tab in pixels.
586
- Only applicable if `new_window` is True.
587
- window_state (Optional[Literal["normal", "minimized", "maximized", "fullscreen"]]): The desired state of the new window.
588
- Only applicable if `new_window` is True.
589
- browser_context_id (Optional[str]): If specified, the new target will be
590
- created in the browser context with this ID. This is useful for
591
- incognito modes or separate user profiles.
592
- enable_begin_frame_control (Optional[bool]): Whether to enable BeginFrame control
593
- for the new target. This is an advanced feature for precise rendering control.
594
- new_window (Optional[bool]): If True, the target will be opened in a new browser window.
595
- If False or None, it will typically open as a new tab.
596
- background (Optional[bool]): If True, the new target will be opened in the background
597
- without immediately gaining focus.
598
- for_tab (Optional[bool]): If True, indicates that the target is intended to be a tab.
599
- This parameter is often used in conjunction with `new_window=False`.
600
- hidden (Optional[bool]): If True, the new target will be created but not immediately
601
- visible.
602
-
603
- Returns:
604
- str: The `targetId` of the newly created browser target. This ID is essential
605
- for interacting with the new target via other CDP commands.
606
- """
607
-
608
- ...
609
-
610
- async def cmd_detach_from_target(self, session_id: Optional[str] = None, target_id: Optional[str] = None,):
611
- """
612
- Detaches the DevTools session from a specific target.
613
-
614
- Detaching stops the ability to send CDP commands and receive events for that target
615
- via the specified session. Either `session_id` or `target_id` must be provided.
616
-
617
- Args:
618
- session_id (Optional[str]): The ID of the DevTools session to detach.
619
- target_id (Optional[str]): The ID of the target from which to detach.
620
- If `session_id` is not provided, this ID is used.
621
- """
622
-
623
- ...
624
-
625
- async def cmd_dispose_browser_context(self, browser_context_id: str,):
626
- """
627
- Disposes of an existing browser context.
628
-
629
- This closes all targets (tabs/windows) associated with the specified browser context
630
- and clears all associated data (e.g., cookies, local storage).
631
-
632
- Args:
633
- browser_context_id (str): The ID of the browser context to dispose of.
634
- """
635
-
636
- ...
637
-
638
- async def cmd_expose_dev_tools_protocol(
639
- self,
640
- target_id: str,
641
- binding_name: Optional[str] = None,
642
- inherit_permissions: Optional[bool] = None,
643
- ):
644
- """
645
- Exposes the DevTools Protocol API to the JavaScript context of a target.
646
-
647
- This allows JavaScript running within the target to directly interact with
648
- the DevTools Protocol by calling methods like `DevTools.evaluate` or `DevTools.send`.
649
-
650
- Args:
651
- target_id (str): The unique ID of the target to expose the protocol to.
652
- binding_name (Optional[str]): The name of the global object that will be
653
- exposed in the target's JavaScript context (default is "DevTools").
654
- inherit_permissions (Optional[bool]): If True, the exposed protocol will
655
- inherit permissions from the current DevTools session.
656
- """
657
-
658
- ...
659
-
660
- async def cmd_get_browser_contexts(self) -> list[str]:
661
- """
662
- Retrieves a list of all existing browser context IDs.
663
-
664
- Returns:
665
- list[str]: A list of strings, where each string is the unique ID of a browser context.
666
-
667
- """
668
-
669
- ...
670
-
671
- async def cmd_get_target_info(self, target_id: Optional[str] = None,) -> Any:
672
- """
673
- Retrieves detailed information about a specific target.
674
-
675
- If `target_id` is not provided, it typically returns information about the
676
- current default target or the browser target if no specific target is active.
677
-
678
- Args:
679
- target_id (Optional[str]): The unique ID of the target to get information for.
680
- If None, information about the current or default target is returned.
681
-
682
- Returns:
683
- Any: The `TargetInfo` object.
684
- """
685
-
686
- ...
687
-
688
- async def cmd_get_targets(self, filter_: Optional[list[Any]] = None,) -> Any:
689
- """
690
- Retrieves a list of all available browser targets.
691
-
692
- This command can optionally filter the returned targets by type or other criteria.
693
-
694
- Args:
695
- filter_ (Optional[Sequence[Any]]): A list of target types or other filter criteria
696
- to narrow down the results. For example, `["page", "iframe"]` to get only
697
- pages and iframes.
698
-
699
- Returns:
700
- Any: A list of `TargetInfo` objects.
701
- """
702
-
703
- ...
704
-
705
- async def cmd_send_message_to_target(
706
- self,
707
- message: str,
708
- session_id: Optional[str] = None,
709
- target_id: Optional[str] = None,
710
- ):
711
- """
712
- Sends a raw DevTools Protocol message to a specific target.
713
-
714
- This is a low-level command for sending arbitrary CDP messages.
715
- Either `session_id` or `target_id` must be provided.
716
-
717
- Args:
718
- message (str): The raw JSON string of the CDP message to send.
719
- This message should conform to the CDP message format (e.g., `{"id": 1, "method": "Page.reload", "params": {}}`).
720
- session_id (Optional[str]): The ID of the DevTools session to send the message through.
721
- target_id (Optional[str]): The ID of the target to send the message to.
722
- If `session_id` is not provided, this ID is used.
723
- """
724
-
725
- ...
726
-
727
- async def context_click_action(
728
- self,
729
- element: Optional[WebElement] = None,
730
- duration: int = 250,
731
- action_chain: Optional[ActionChains] = None
732
- ) -> ActionChains:
733
- """
734
- Adds a context-click (right-click) action. Performs the action on the specified element or the current mouse position.
735
-
736
- If an existing ActionChains object is provided via `action_chain`, this action
737
- is appended to it. Otherwise, a new ActionChains object is created using
738
- `self.build_action_chains` with the specified duration before adding the action.
739
-
740
- Args:
741
- element (Optional[WebElement]): The web element to context-click. If None, performs
742
- the context-click at the current mouse cursor position. Defaults to None.
743
- duration (int): The duration in milliseconds to use when creating a new
744
- ActionChains instance if `action_chain` is None. Defaults to 250.
745
- action_chain (Optional[ActionChains]): An existing ActionChains instance to append
746
- this action to. If None, a new chain is created. Defaults to None.
747
-
748
- Returns:
749
- ActionChains: The ActionChains instance (either the one passed in or a new one)
750
- with the context-click action added, allowing for method chaining.
751
- """
752
-
753
- ...
754
-
755
- @property
756
- def cookies(self) -> list[dict[str, Any]]:
757
- """
758
- Gets all cookies visible to the current page.
759
-
760
- Returns:
761
- list[dict[str, Any]]: A list of dictionaries, where each dictionary represents a cookie.
762
- """
763
-
764
- ...
765
-
766
- @property
767
- def current_url(self) -> str:
768
- """
769
- Gets the current URL.
770
-
771
- Retrieves the URL of the current page loaded in the browser window under WebDriver control.
772
-
773
- Returns:
774
- str: The current URL of the webpage.
775
- """
776
-
777
- ...
778
-
779
- @property
780
- def current_window_handle(self) -> str:
781
- """
782
- Gets the current window handle.
783
-
784
- Retrieves the handle of the currently active browser window or tab. Window handles are unique identifiers
785
- used by WebDriver to distinguish between different browser windows.
786
-
787
- Returns:
788
- str: The current window handle.
789
- """
790
-
791
- ...
792
-
793
- async def delete_all_cookies(self):
794
- """
795
- Deletes all cookies from the current session.
796
- """
797
-
798
- ...
799
-
800
- async def delete_cookie(self, name: str):
801
- """
802
- Deletes a single cookie by its name from the current session.
803
-
804
- Args:
805
- name (str): The name of the cookie to delete.
806
- """
807
-
808
- ...
809
-
810
- async def delete_downloadable_files(self):
811
- """
812
- Deletes all downloadable files.
813
- """
814
-
815
- ...
816
-
817
- async def double_click_action(
818
- self,
819
- element: Optional[WebElement] = None,
820
- duration: int = 250,
821
- action_chain: Optional[ActionChains] = None
822
- ) -> ActionChains:
823
- """
824
- Adds a double-click action. Performs the action on the specified element or the current mouse position.
825
-
826
- If an existing ActionChains object is provided via `action_chain`, this action
827
- is appended to it. Otherwise, a new ActionChains object is created using
828
- `self.build_action_chains` with the specified duration before adding the action.
829
-
830
- Args:
831
- element (Optional[WebElement]): The web element to double-click. If None, double-clicks
832
- at the current mouse cursor position. Defaults to None.
833
- duration (int): The duration in milliseconds to use when creating a new
834
- ActionChains instance if `action_chain` is None. Defaults to 250.
835
- action_chain (Optional[ActionChains]): An existing ActionChains instance to append
836
- this action to. If None, a new chain is created. Defaults to None.
837
-
838
- Returns:
839
- ActionChains: The ActionChains instance (either the one passed in or a new one)
840
- with the double-click action added, allowing for method chaining.
841
- """
842
-
843
- ...
844
-
845
- async def download_file(self, file_name: str, target_directory: pathlib.Path):
846
- """
847
- Downloads a file from the browser.
848
-
849
- Args:
850
- file_name (str): The name of the file to download as it appears in the browser's download list.
851
- target_directory (pathlib.Path): The local directory where the file should be saved.
852
- """
853
-
854
- ...
855
-
856
- async def drag_and_drop_action(
857
- self,
858
- source_element: WebElement,
859
- target_element: WebElement,
860
- duration: int = 250,
861
- action_chain: Optional[ActionChains] = None
862
- ) -> ActionChains:
863
- """
864
- Adds a drag-and-drop action from a source element to a target element.
865
-
866
- Combines click-and-hold on the source, move to the target, and release.
867
- If an existing ActionChains object is provided via `action_chain`, this action
868
- is appended to it. Otherwise, a new ActionChains object is created using
869
- `self.build_action_chains` with the specified duration before adding the action.
870
-
871
- Args:
872
- source_element (WebElement): The element to click and hold (the start of the drag).
873
- target_element (WebElement): The element to move to and release over (the end of the drop).
874
- duration (int): The duration in milliseconds to use when creating a new
875
- ActionChains instance if `action_chain` is None. Defaults to 250.
876
- action_chain (Optional[ActionChains]): An existing ActionChains instance to append
877
- this action to. If None, a new chain is created. Defaults to None.
878
-
879
- Returns:
880
- ActionChains: The ActionChains instance (either the one passed in or a new one)
881
- with the drag-and-drop action added, allowing for method chaining.
882
- """
883
-
884
- ...
885
-
886
- async def drag_and_drop_by_offset_action(
887
- self,
888
- source_element: WebElement,
889
- xoffset: int,
890
- yoffset: int,
891
- duration: int = 250,
892
- action_chain: Optional[ActionChains] = None
893
- ) -> ActionChains:
894
- """
895
- Adds a drag-and-drop action from a source element by a given offset.
896
-
897
- Combines click-and-hold on the source, move by the offset, and release.
898
- If an existing ActionChains object is provided via `action_chain`, this action
899
- is appended to it. Otherwise, a new ActionChains object is created using
900
- `self.build_action_chains` with the specified duration before adding the action.
901
-
902
- Args:
903
- source_element (WebElement): The element to click and hold (the start of the drag).
904
- xoffset (int): The horizontal distance to move the mouse.
905
- yoffset (int): The vertical distance to move the mouse.
906
- duration (int): The duration in milliseconds to use when creating a new
907
- ActionChains instance if `action_chain` is None. Defaults to 250.
908
- action_chain (Optional[ActionChains]): An existing ActionChains instance to append
909
- this action to. If None, a new chain is created. Defaults to None.
910
-
911
- Returns:
912
- ActionChains: The ActionChains instance (either the one passed in or a new one)
913
- with the drag-and-drop by offset action added, allowing for method chaining.
914
- """
915
-
916
- ...
917
-
918
- @property
919
- def driver(self) -> Optional[Union[webdriver.Chrome, webdriver.Edge, webdriver.Firefox]]:
920
- """
921
- Gets the underlying Selenium WebDriver instance associated with this object.
922
-
923
- This property provides direct access to the WebDriver object (e.g., Chrome, Edge, Firefox)
924
- that is being controlled, allowing for direct Selenium operations if needed.
925
-
926
- Returns:
927
- Optional[Union[webdriver.Chrome, webdriver.Edge, webdriver.Firefox]]:
928
- The active WebDriver instance, or None if no driver is currently set or active.
929
- """
930
-
931
- ...
932
-
933
- async def execute_cdp_cmd(self, cmd: str, cmd_args: dict[str, Any]) -> Any:
934
- """
935
- Executes a Chrome DevTools Protocol (CDP) command.
936
-
937
- This method allows direct interaction with the browser's underlying DevTools Protocol,
938
- enabling fine-grained control over browser behavior, network, page rendering, and more.
939
-
940
- Args:
941
- cmd (str): The name of the CDP command to execute (e.g., "Page.navigate", "Network.enable", "Emulation.setDeviceMetricsOverride").
942
- cmd_args (dict[str, Any]): A dictionary of arguments specific to the given CDP command.
943
- The structure and required keys depend on the `cmd` being executed, as defined
944
- by the Chrome DevTools Protocol specification.
945
-
946
- Returns:
947
- Any: The result of the CDP command execution. The type and structure of the
948
- returned value depend on the specific `cmd` and its defined return type
949
- in the CDP specification.
950
- """
951
-
952
- ...
953
-
954
- async def execute_js_script(self, script: str, *args) -> Any:
955
- """
956
- Executes a JavaScript script in the current browser context.
957
-
958
- Executes arbitrary JavaScript code within the currently loaded webpage. This allows for
959
- performing actions that are not directly supported by WebDriver commands, such as complex
960
- DOM manipulations or accessing browser APIs.
961
-
962
- Args:
963
- script (str): The JavaScript code to execute as a string.
964
- *args: Arguments to pass to the JavaScript script. These are accessible in the script as `arguments[0]`, `arguments[1]`, etc.
965
-
966
- Returns:
967
- Any: The result of the JavaScript execution. JavaScript return values are converted to Python types.
968
- For example, JavaScript objects become Python dictionaries, arrays become lists, and primitives are converted directly.
969
- """
970
-
971
- ...
972
-
973
- @property
974
- def fedcm(self) -> FedCM:
975
- """
976
- Gets the FedCM (Federated Credential Management) interface.
977
-
978
- Returns:
979
- FedCM: An object providing methods to interact with the FedCM API in the browser.
980
- """
981
-
982
- ...
983
-
984
- @property
985
- def fedcm_dialog(self) -> Dialog:
986
- """
987
- Gets the FedCM dialog interface.
988
-
989
- Returns:
990
- Dialog: An object providing methods to interact with the FedCM dialog.
991
- """
992
-
993
- ...
994
-
995
- async def find_inner_web_element(
996
- self,
997
- parent_element: WebElement,
998
- by: str,
999
- value: str,
1000
- temp_implicitly_wait: Optional[int] = None,
1001
- temp_page_load_timeout: Optional[int] = None,
1002
- temp_script_timeout: Optional[float] = None,
1003
- ) -> WebElement:
1004
- """
1005
- Finds a single web element within another element.
1006
-
1007
- Searches for a specific web element that is a descendant of a given parent web element.
1008
- This is useful for locating elements within a specific section or component of a webpage.
1009
-
1010
- Args:
1011
- parent_element (WebElement): The parent web element to search within. The search is scoped to this element's descendants.
1012
- by (str): Locator strategy to use for finding the element (e.g., By.ID, By.XPATH).
1013
- value (str): Locator value. The actual string used by the locator strategy to find the element.
1014
- temp_implicitly_wait (Optional[int]): Temporary implicit wait time in seconds for this operation. Overrides default if provided. Defaults to None.
1015
- temp_page_load_timeout (Optional[int]): Temporary page load timeout in seconds for this operation. Overrides default if provided. Defaults to None.
1016
- temp_script_timeout (Optional[int]): Temporary script timeout in seconds for this operation. Overrides default if provided. Defaults to None.
1017
-
1018
- Returns:
1019
- WebElement: The found web element. If no element is found within the timeout, a `NoSuchElementException` is raised.
1020
- """
1021
-
1022
- ...
1023
-
1024
- async def find_inner_web_elements(
1025
- self,
1026
- parent_element: WebElement,
1027
- by: str,
1028
- value: str,
1029
- temp_implicitly_wait: Optional[int] = None,
1030
- temp_page_load_timeout: Optional[int] = None,
1031
- temp_script_timeout: Optional[float] = None,
1032
- ) -> list[WebElement]:
1033
- """
1034
- Finds multiple web elements within another element.
1035
-
1036
- Searches for all web elements that match the given criteria and are descendants of a
1037
- specified parent web element. Returns a list of all matching elements found within the parent.
1038
-
1039
- Args:
1040
- parent_element (WebElement): The parent web element to search within. The search is limited to this element's children.
1041
- by (str): Locator strategy to use (e.g., By.CLASS_NAME, By.CSS_SELECTOR).
1042
- value (str): Locator value. Used in conjunction with the 'by' strategy to locate elements.
1043
- temp_implicitly_wait (Optional[int]): Temporary implicit wait time in seconds for this operation. Defaults to None.
1044
- temp_page_load_timeout (Optional[int]): Temporary page load timeout in seconds for this operation. Defaults to None.
1045
- temp_script_timeout (Optional[int]): Temporary script timeout in seconds for this operation. Overrides default if provided. Defaults to None.
1046
-
1047
- Returns:
1048
- list[WebElement]: A list of found web elements. Returns an empty list if no elements are found.
1049
- """
1050
-
1051
- ...
1052
-
1053
- async def find_web_element(
1054
- self,
1055
- by: str,
1056
- value: str,
1057
- temp_implicitly_wait: Optional[int] = None,
1058
- temp_page_load_timeout: Optional[int] = None,
1059
- temp_script_timeout: Optional[float] = None,
1060
- ) -> WebElement:
1061
- """
1062
- Finds a single web element on the page.
1063
-
1064
- Searches the entire webpage DOM for the first web element that matches the specified locator
1065
- strategy and value. Returns the found element or raises an exception if no element is found within the timeout.
1066
-
1067
- Args:
1068
- by (str): Locator strategy to use (e.g., By.ID, By.NAME).
1069
- value (str): Locator value. Used with the 'by' strategy to identify the element.
1070
- temp_implicitly_wait (Optional[int]): Temporary implicit wait time in seconds for this operation. Defaults to None.
1071
- temp_page_load_timeout (Optional[int]): Temporary page load timeout in seconds for this operation. Defaults to None.
1072
- temp_script_timeout (Optional[int]): Temporary script timeout in seconds for this operation. Overrides default if provided. Defaults to None.
1073
-
1074
- Returns:
1075
- WebElement: The found web element.
1076
- """
1077
-
1078
- ...
1079
-
1080
- async def find_web_elements(
1081
- self,
1082
- by: str,
1083
- value: str,
1084
- temp_implicitly_wait: Optional[int] = None,
1085
- temp_page_load_timeout: Optional[int] = None,
1086
- temp_script_timeout: Optional[float] = None,
1087
- ) -> list[WebElement]:
1088
- """
1089
- Finds multiple web elements on the page.
1090
-
1091
- Searches the entire webpage for all web elements that match the specified locator strategy and value.
1092
- Returns a list containing all matching elements. If no elements are found, an empty list is returned.
1093
-
1094
- Args:
1095
- by (str): Locator strategy (e.g., By.TAG_NAME, By.LINK_TEXT).
1096
- value (str): Locator value. Used with the 'by' strategy to locate elements.
1097
- temp_implicitly_wait (Optional[int]): Temporary implicit wait time in seconds for this operation. Defaults to None.
1098
- temp_page_load_timeout (Optional[int]): Temporary page load timeout in seconds for this operation. Defaults to None.
1099
- temp_script_timeout (Optional[int]): Temporary script timeout in seconds for this operation. Overrides default if provided. Defaults to None.
1100
-
1101
- Returns:
1102
- list[WebElement]: A list of found web elements. Returns an empty list if no elements are found.
1103
- """
1104
-
1105
- ...
1106
-
1107
- async def fullscreen_window(self):
1108
- """
1109
- Makes the current browser window full screen.
1110
- """
1111
-
1112
- ...
1113
-
1114
- async def get_cookie(self, name: str) -> Optional[dict[str, Any]]:
1115
- """
1116
- Gets a single cookie by its name.
1117
-
1118
- Args:
1119
- name (str): The name of the cookie to retrieve.
1120
-
1121
- Returns:
1122
- Optional[dict[str, Any]]: A dictionary representing the cookie if found, otherwise None.
1123
- """
1124
-
1125
- ...
1126
-
1127
- async def get_credentials(self) -> list[Credential]:
1128
- """
1129
- Gets a list of all registered WebAuthn credentials.
1130
-
1131
- Returns:
1132
- list[Credential]: A list of `Credential` objects.
1133
- """
1134
-
1135
- ...
1136
-
1137
- async def get_document_scroll_size(self) -> Size:
1138
- """
1139
- Gets the total scrollable dimensions of the HTML document.
1140
-
1141
- Executes a predefined JavaScript snippet to retrieve the document's scrollWidth
1142
- and scrollHeight.
1143
-
1144
- Returns:
1145
- Size: A TypedDict where 'width' represents the document's scrollWidth,
1146
- 'height' represents the scrollHeight.
1147
- """
1148
-
1149
- ...
1150
-
1151
- async def get_downloadable_files(self) -> list[str]:
1152
- """
1153
- Gets a list of downloadable files.
1154
-
1155
- Returns:
1156
- list[str]: A list of file names that are currently available for download.
1157
- """
1158
-
1159
- ...
1160
-
1161
- async def get_element_css_style(self, element: WebElement) -> dict[str, str]:
1162
- """
1163
- Retrieves the computed CSS style of a WebElement.
1164
-
1165
- Uses JavaScript to get all computed CSS properties and their values for a given web element.
1166
- Returns a dictionary where keys are CSS property names and values are their computed values.
1167
-
1168
- Args:
1169
- element (WebElement): The WebElement for which to retrieve the CSS style.
1170
-
1171
- Returns:
1172
- dict[str, str]: A dictionary of CSS property names and their computed values as strings.
1173
- """
1174
-
1175
- ...
1176
-
1177
- async def get_element_rect_in_viewport(self, element: WebElement) -> Rectangle:
1178
- """
1179
- Gets the position and dimensions of an element relative to the viewport.
1180
-
1181
- Executes a predefined JavaScript snippet that calculates the element's bounding rectangle
1182
- as seen in the current viewport.
1183
-
1184
- Args:
1185
- element (WebElement): The Selenium WebElement whose rectangle is needed.
1186
-
1187
- Returns:
1188
- Rectangle: A TypedDict containing the 'x', 'y', 'width', and 'height' of the element
1189
- relative to the viewport's top-left corner. 'x' and 'y' can be negative
1190
- if the element is partially scrolled out of view to the top or left.
1191
- """
1192
-
1193
- ...
1194
-
1195
- async def get_fedcm_dialog(
1196
- self,
1197
- ignored_exceptions: Any,
1198
- timeout: int = 5,
1199
- poll_frequency: float = 0.5
1200
- ) -> Dialog:
1201
- """
1202
- Waits for and retrieves the FedCM dialog.
1203
-
1204
- Args:
1205
- ignored_exceptions (Any): Exceptions to ignore while waiting for the dialog.
1206
- timeout (int): The maximum time to wait for the dialog to appear, in seconds. Defaults to 5.
1207
- poll_frequency (float): How often to check for the dialog's presence, in seconds. Defaults to 0.5.
1208
-
1209
- Returns:
1210
- Dialog: The FedCM dialog object.
1211
- """
1212
-
1213
- ...
1214
-
1215
- async def get_random_element_point(self, element: WebElement) -> ActionPoint:
1216
- """
1217
- Gets the coordinates of a random point within an element, relative to the viewport origin.
1218
-
1219
- Calculates a random point within the visible portion of the element relative to the
1220
- element's own top-left corner. It then adds the element's top-left coordinates
1221
- (relative to the viewport) to get the final coordinates of the random point,
1222
- also relative to the viewport's top-left origin (0,0).
1223
-
1224
- Args:
1225
- element (WebElement): The target element within which to find a random point.
1226
-
1227
- Returns:
1228
- ActionPoint: An ActionPoint named tuple containing the 'x' and 'y' coordinates
1229
- of the random point within the element, relative to the viewport origin.
1230
- """
1231
-
1232
- ...
1233
-
1234
- async def get_random_element_point_in_viewport(self, element: WebElement, step: int = 1) -> Optional[Position]:
1235
- """
1236
- Calculates a random point within the visible portion of a given element in the viewport.
1237
-
1238
- Executes a predefined JavaScript snippet that determines the element's bounding box
1239
- relative to the viewport, calculates the intersection of this box with the viewport,
1240
- and then selects a random point within that intersection, potentially aligned to a grid defined by `step`.
1241
-
1242
- Args:
1243
- element (WebElement): The Selenium WebElement to find a random point within.
1244
- step (int): Defines the grid step for selecting the random point. The coordinates
1245
- will be multiples of this step within the valid range. Defaults to 1 (any pixel).
1246
-
1247
- Returns:
1248
- Position: A TypedDict containing the integer 'x' and 'y' coordinates of a random point
1249
- within the element's visible area in the viewport. Coordinates are relative
1250
- to the element's top-left corner (0,0).
1251
- """
1252
-
1253
- ...
1254
-
1255
- async def get_screenshot_as_base64(self) -> str:
1256
- """
1257
- Gets the screenshot of the current page as a Base64 encoded string.
1258
-
1259
- Returns:
1260
- str: A Base64 encoded string representing the screenshot.
1261
- """
1262
-
1263
- ...
1264
-
1265
- async def get_screenshot_as_file(self, file_path: pathlib.Path) -> bool:
1266
- """
1267
- Saves a screenshot of the current page to a specified file.
1268
-
1269
- Args:
1270
- file_path (pathlib.Path): The path where the screenshot should be saved.
1271
-
1272
- Returns:
1273
- bool: True if the screenshot was successfully saved, False otherwise.
1274
- """
1275
-
1276
- ...
1277
-
1278
- async def get_screenshot_as_png(self) -> bytes:
1279
- """
1280
- Gets the screenshot of the current page as a PNG image in bytes.
1281
-
1282
- Returns:
1283
- bytes: The screenshot as PNG formatted bytes.
1284
- """
1285
-
1286
- ...
1287
-
1288
- async def get_vars_for_remote(self) -> RemoteConnection:
1289
- """
1290
- Gets variables necessary to create a remote WebDriver instance.
1291
-
1292
- Provides the command executor and session ID of the current WebDriver instance.
1293
- These are needed to re-establish a connection to the same browser session from a different WebDriver client,
1294
- for example, in a distributed testing environment.
1295
-
1296
- Returns:
1297
- RemoteConnection: The command executor (for establishing connection).
1298
- """
1299
-
1300
- ...
1301
-
1302
- async def get_viewport_position(self) -> Position:
1303
- """
1304
- Gets the current scroll position of the viewport relative to the document origin (0,0).
1305
-
1306
- Executes a predefined JavaScript snippet to retrieve window.scrollX and window.scrollY.
1307
-
1308
- Returns:
1309
- Position: A TypedDict containing the 'x' (horizontal scroll offset) and
1310
- 'y' (vertical scroll offset) of the viewport.
1311
- """
1312
-
1313
- ...
1314
-
1315
- async def get_viewport_rect(self) -> Rectangle:
1316
- """
1317
- Gets the position and dimensions of the viewport relative to the document origin.
1318
-
1319
- Combines the scroll position (top-left corner) and the viewport dimensions.
1320
- Executes a predefined JavaScript snippet.
1321
-
1322
- Returns:
1323
- Rectangle: A TypedDict where 'x' and 'y' represent the current scroll offsets
1324
- (window.pageXOffset, window.pageYOffset) and 'width' and 'height' represent
1325
- the viewport dimensions (window.innerWidth, window.innerHeight).
1326
- """
1327
-
1328
- ...
1329
-
1330
- async def get_viewport_size(self) -> Size:
1331
- """
1332
- Gets the current dimensions (width and height) of the browser's viewport.
1333
-
1334
- Executes a predefined JavaScript snippet to retrieve the inner width and height
1335
- of the window.
1336
-
1337
- Returns:
1338
- Size: A TypedDict containing the 'width' and 'height' of the viewport in pixels.
1339
- """
1340
-
1341
- ...
1342
-
1343
- async def get_window_handle(self, window: Optional[Union[str, int]] = None) -> str:
1344
- """
1345
- Retrieves a window handle string based on the provided identifier.
1346
-
1347
- If the identifier is already a string, it's assumed to be a valid handle and returned directly.
1348
- If it's an integer, it's treated as an index into the list of currently open window handles.
1349
- If it's None or not provided, the handle of the currently active window is returned.
1350
-
1351
- Args:
1352
- window (Optional[Union[str, int]]): The identifier for the desired window handle.
1353
-
1354
- - str: Assumed to be the window handle itself.
1355
- - int: Index into the list of window handles (self.driver.window_handles).
1356
- - None: Get the handle of the currently focused window.
1357
-
1358
- Returns:
1359
- str: The window handle string corresponding to the input identifier.
1360
- """
1361
-
1362
- ...
1363
-
1364
- @property
1365
- def is_active(self) -> bool:
1366
- """
1367
- Checks if the WebDriver instance is currently active and connected.
1368
-
1369
- This property provides a way to determine the current status of the WebDriver.
1370
- It reflects whether the WebDriver is initialized and considered operational.
1371
-
1372
- Returns:
1373
- bool: True if the WebDriver is active, False otherwise.
1374
- """
1375
-
1376
- ...
1377
-
1378
- async def key_down_action(
1379
- self,
1380
- value: str,
1381
- element: Optional[WebElement] = None,
1382
- duration: int = 250,
1383
- action_chain: Optional[ActionChains] = None
1384
- ) -> ActionChains:
1385
- """
1386
- Adds a key down (press and hold) action for a specific modifier key.
1387
-
1388
- Sends the key press to the specified element or the currently focused element.
1389
- If an existing ActionChains object is provided via `action_chain`, this action
1390
- is appended to it. Otherwise, a new ActionChains object is created using
1391
- `self.build_action_chains` with the specified duration before adding the action.
1392
-
1393
- Args:
1394
- value (str): The modifier key to press (e.g., Keys.CONTROL, Keys.SHIFT).
1395
- element (Optional[WebElement]): The element to send the key press to. If None,
1396
- sends to the currently focused element. Defaults to None.
1397
- duration (int): The duration in milliseconds to use when creating a new
1398
- ActionChains instance if `action_chain` is None. Defaults to 250.
1399
- action_chain (Optional[ActionChains]): An existing ActionChains instance to append
1400
- this action to. If None, a new chain is created. Defaults to None.
1401
-
1402
- Returns:
1403
- ActionChains: The ActionChains instance (either the one passed in or a new one)
1404
- with the key down action added, allowing for method chaining.
1405
- """
1406
-
1407
- ...
1408
-
1409
- async def key_up_action(
1410
- self,
1411
- value: str,
1412
- element: Optional[WebElement] = None,
1413
- duration: int = 250,
1414
- action_chain: Optional[ActionChains] = None
1415
- ) -> ActionChains:
1416
- """
1417
- Adds a key up (release) action for a specific modifier key.
1418
-
1419
- Sends the key release to the specified element or the currently focused element.
1420
- If an existing ActionChains object is provided via `action_chain`, this action
1421
- is appended to it. Otherwise, a new ActionChains object is created using
1422
- `self.build_action_chains` with the specified duration before adding the action. Typically used after `key_down_action`.
1423
-
1424
- Args:
1425
- value (str): The modifier key to release (e.g., Keys.CONTROL, Keys.SHIFT).
1426
- element (Optional[WebElement]): The element to send the key release to. If None,
1427
- sends to the currently focused element. Defaults to None.
1428
- duration (int): The duration in milliseconds to use when creating a new
1429
- ActionChains instance if `action_chain` is None. Defaults to 250.
1430
- action_chain (Optional[ActionChains]): An existing ActionChains instance to append
1431
- this action to. If None, a new chain is created. Defaults to None.
1432
-
1433
- Returns:
1434
- ActionChains: The ActionChains instance (either the one passed in or a new one)
1435
- with the key up action added, allowing for method chaining.
1436
- """
1437
-
1438
- ...
1439
-
1440
- async def maximize_window(self):
1441
- """
1442
- Maximizes the current browser window.
1443
- """
1444
-
1445
- ...
1446
-
1447
- async def minimize_window(self):
1448
- """
1449
- Minimizes the current browser window.
1450
- """
1451
-
1452
- ...
1453
-
1454
- async def move_to_element_action(
1455
- self,
1456
- element: WebElement,
1457
- duration: int = 250,
1458
- action_chain: Optional[ActionChains] = None
1459
- ) -> ActionChains:
1460
- """
1461
- Adds a move mouse cursor action to the specified web element.
1462
-
1463
- If an existing ActionChains object is provided via `action_chain`, this action
1464
- is appended to it. Otherwise, a new ActionChains object is created using
1465
- `self.build_action_chains` with the specified duration before adding the action.
1466
-
1467
- Args:
1468
- element (WebElement): The target web element to move the mouse to.
1469
- duration (int): The duration in milliseconds to use when creating a new
1470
- ActionChains instance if `action_chain` is None. Defaults to 250.
1471
- action_chain (Optional[ActionChains]): An existing ActionChains instance to append
1472
- this action to. If None, a new chain is created. Defaults to None.
1473
-
1474
- Returns:
1475
- ActionChains: The ActionChains instance (either the one passed in or a new one)
1476
- with the move action added, allowing for method chaining.
1477
- """
1478
-
1479
- ...
1480
-
1481
- async def move_to_element_with_offset_action(
1482
- self,
1483
- element: WebElement,
1484
- xoffset: int,
1485
- yoffset: int,
1486
- duration: int = 250,
1487
- action_chain: Optional[ActionChains] = None
1488
- ) -> ActionChains:
1489
- """
1490
- Adds an action to move the mouse cursor to an offset from the center of a specified element.
1491
-
1492
- If an existing ActionChains object is provided via `action_chain`, this action
1493
- is appended to it. Otherwise, a new ActionChains object is created using
1494
- `self.build_action_chains` with the specified duration before adding the action.
1495
-
1496
- Args:
1497
- element (WebElement): The target web element to base the offset from.
1498
- xoffset (int): The horizontal offset from the element's center. Positive is right, negative is left.
1499
- yoffset (int): The vertical offset from the element's center. Positive is down, negative is up.
1500
- duration (int): The duration in milliseconds to use when creating a new
1501
- ActionChains instance if `action_chain` is None. Defaults to 250.
1502
- action_chain (Optional[ActionChains]): An existing ActionChains instance to append
1503
- this action to. If None, a new chain is created. Defaults to None.
1504
-
1505
- Returns:
1506
- ActionChains: The ActionChains instance (either the one passed in or a new one)
1507
- with the move-with-offset action added, allowing for method chaining.
1508
- """
1509
-
1510
- ...
1511
-
1512
- async def open_new_tab(self, link: str = ""):
1513
- """
1514
- Opens a new tab with the given URL.
1515
-
1516
- Opens a new browser tab and optionally navigates it to a specified URL. If no URL is provided, a blank tab is opened.
1517
-
1518
- Args:
1519
- link (str): URL to open in the new tab. If empty, opens a blank tab. Defaults to "".
1520
- """
1521
-
1522
- ...
1523
-
1524
- @property
1525
- def orientation(self) -> Literal["LANDSCAPE", "PORTRAIT"]:
1526
- """
1527
- Gets the current screen orientation (LANDSCAPE or PORTRAIT).
1528
-
1529
- Returns:
1530
- Literal["LANDSCAPE", "PORTRAIT"]: The current screen orientation.
1531
- """
1532
-
1533
- ...
1534
-
1535
- @orientation.setter
1536
- def orientation(self, value: Literal["LANDSCAPE", "PORTRAIT"]):
1537
- """
1538
- Sets the screen orientation.
1539
-
1540
- Args:
1541
- value (Literal["LANDSCAPE", "PORTRAIT"]): The desired screen orientation.
1542
- """
1543
-
1544
- ...
1545
-
1546
- @property
1547
- def page_source(self) -> str:
1548
- """
1549
- Gets the HTML source code of the current page.
1550
-
1551
- Returns:
1552
- str: The HTML source code as a string.
1553
- """
1554
-
1555
- ...
1556
-
1557
- async def print_page(self, print_options: Optional[PrintOptions] = None) -> str:
1558
- """
1559
- Prints the current page to PDF.
1560
-
1561
- Args:
1562
- print_options (Optional[PrintOptions]): Options for printing the page (e.g., orientation, scale).
1563
-
1564
- Returns:
1565
- str: A Base64 encoded string of the PDF document.
1566
- """
1567
-
1568
- ...
1569
-
1570
- @property
1571
- def rect(self) -> WindowRect:
1572
- """
1573
- Gets the window rectangle.
1574
-
1575
- Retrieves the current position and size of the browser window as a `WindowRect` object.
1576
- This object contains the x and y coordinates of the window's top-left corner, as well as its width and height.
1577
-
1578
- Returns:
1579
- WindowRect: The window rectangle object containing x, y, width, and height.
1580
- """
1581
-
1582
- ...
1583
-
1584
- async def refresh_webdriver(self):
1585
- """
1586
- Refreshes the current page.
1587
-
1588
- Reloads the currently loaded webpage in the browser. This action fetches the latest version of the page from the server.
1589
- """
1590
-
1591
- ...
1592
-
1593
- async def release_action(
1594
- self,
1595
- element: Optional[WebElement] = None,
1596
- duration: int = 250,
1597
- action_chain: Optional[ActionChains] = None
1598
- ) -> ActionChains:
1599
- """
1600
- Adds a release mouse button action. Releases the depressed left mouse button on the specified element or the current mouse position.
1601
-
1602
- If an existing ActionChains object is provided via `action_chain`, this action
1603
- is appended to it. Otherwise, a new ActionChains object is created using
1604
- `self.build_action_chains` with the specified duration before adding the action. Typically used after a `click_and_hold_action`.
1605
-
1606
- Args:
1607
- element (Optional[WebElement]): The web element on which to release the mouse button.
1608
- If None, releases at the current mouse cursor position. Defaults to None.
1609
- duration (int): The duration in milliseconds to use when creating a new
1610
- ActionChains instance if `action_chain` is None. Defaults to 250.
1611
- action_chain (Optional[ActionChains]): An existing ActionChains instance to append
1612
- this action to. If None, a new chain is created. Defaults to None.
1613
-
1614
- Returns:
1615
- ActionChains: The ActionChains instance (either the one passed in or a new one)
1616
- with the release action added, allowing for method chaining.
1617
- """
1618
-
1619
- ...
1620
-
1621
- async def remote_connect_driver(self, command_executor: Union[str, RemoteConnection]):
1622
- """
1623
- Connects to an existing remote WebDriver session.
1624
-
1625
- This method establishes a connection to a remote Selenium WebDriver server and reuses an existing browser session of Browser.
1626
- It allows you to control a browser instance that is already running remotely, given the command executor URL and session ID of that session.
1627
-
1628
- Args:
1629
- command_executor (Union[str, RemoteConnection]): The URL of the remote WebDriver server or a `RemoteConnection` object.
1630
- """
1631
-
1632
- ...
1633
-
1634
- async def remove_all_credentials(self):
1635
- """
1636
- Removes all registered WebAuthn credentials from the browser's virtual authenticator.
1637
- """
1638
-
1639
- ...
1640
-
1641
- async def remove_captcha_worker(self, name: str):
1642
- """
1643
- Removes a captcha worker from the list by its name.
1644
-
1645
- The method iterates through the registered workers and removes the first one
1646
- that matches the given name. If no worker with the specified name is found,
1647
- no action is taken.
1648
-
1649
- Args:
1650
- name (str): The name of the captcha worker to remove.
1651
- """
1652
-
1653
- ...
1654
-
1655
- async def remove_credential(self, credential_id: Union[str, bytearray]):
1656
- """
1657
- Removes a specific WebAuthn credential by its ID.
1658
-
1659
- Args:
1660
- credential_id (Union[str, bytearray]): The ID of the credential to remove.
1661
- """
1662
-
1663
- ...
1664
-
1665
- async def remove_virtual_authenticator(self):
1666
- """
1667
- Removes the currently active virtual authenticator from the browser.
1668
- """
1669
-
1670
- ...
1671
-
1672
- async def reset_captcha_workers(self, captcha_workers: Optional[list["CaptchaWorkerSettings"]] = None):
1673
- """
1674
- Resets the list of captcha workers, optionally replacing it with a new sequence.
1675
-
1676
- If `captcha_workers` is provided, the internal list is set to this new sequence.
1677
- If `captcha_workers` is None, the internal list is cleared.
1678
-
1679
- Args:
1680
- captcha_workers (Optional[list["CaptchaWorkerSettings"]]): An optional
1681
- sequence of `CaptchaWorkerSettings` to replace the current list of workers.
1682
- Defaults to None, which clears the list.
1683
- """
1684
-
1685
- ...
1686
-
1687
- async def reset_settings(
1688
- self,
1689
- flags: Optional["BrowserFlags"] = None,
1690
- window_rect: Optional[WindowRect] = None,
1691
- trio_tokens_limit: Union[int, float] = 40,
1692
- ):
1693
- """
1694
- Resets all configurable browser settings to their default or specified values.
1695
-
1696
- This method resets various browser settings to the provided values. If no value
1697
- is provided for certain settings, they are reset to their default states.
1698
- This can only be done when the browser is not active.
1699
-
1700
- Args:
1701
- flags (Optional["BrowserFlags"]): A dictionary of flags to apply. If provided, existing flags are cleared and replaced. If None, all flags are cleared.
1702
- window_rect (Optional[WindowRect]): Updates the window rectangle settings. Defaults to a new WindowRect().
1703
- trio_tokens_limit (Union[int, float]): The total number of tokens for the Trio capacity limiter. Defaults to 40.
1704
- """
1705
-
1706
- ...
1707
-
1708
- async def restart_webdriver(
1709
- self,
1710
- flags: Optional[Union["BrowserFlags", _any_flags_mapping]] = None,
1711
- window_rect: Optional[WindowRect] = None,
1712
- trio_tokens_limit: Optional[Union[int, float]] = None,
1713
- ):
1714
- """
1715
- Restarts the WebDriver and browser session gracefully.
1716
-
1717
- Performs a clean restart by first closing the existing WebDriver session and browser
1718
- (using `close_webdriver`), and then initiating a new session (using `start_webdriver`)
1719
- with potentially updated settings. If settings arguments are provided, they override
1720
- the existing settings for the new session; otherwise, the current settings are used.
1721
-
1722
- Args:
1723
- flags (Optional[Union["BrowserFlags", _any_flags_mapping]]): Override flags for the new session. Defaults to None (use current).
1724
- window_rect (Optional[WindowRect]): Override window rectangle for the new session. Defaults to None (use current).
1725
- trio_tokens_limit (Optional[Union[int, float]]): Override Trio token limit for the new session. Defaults to None (use current).
1726
- """
1727
-
1728
- ...
1729
-
1730
- async def scroll_by_amount_action(
1731
- self,
1732
- delta_x: int,
1733
- delta_y: int,
1734
- duration: int = 250,
1735
- action_chain: Optional[ActionChains] = None
1736
- ) -> ActionChains:
1737
- """
1738
- Adds a scroll action to the current mouse position by the specified amounts.
1739
-
1740
- If an existing ActionChains object is provided via `action_chain`, this action
1741
- is appended to it. Otherwise, a new ActionChains object is created using
1742
- `self.build_action_chains` with the specified duration before adding the action.
1743
-
1744
- Args:
1745
- delta_x (int): The amount to scroll horizontally. Positive scrolls right, negative scrolls left.
1746
- delta_y (int): The amount to scroll vertically. Positive scrolls down, negative scrolls up.
1747
- duration (int): The duration in milliseconds to use when creating a new
1748
- ActionChains instance if `action_chain` is None. Defaults to 250.
1749
- action_chain (Optional[ActionChains]): An existing ActionChains instance to append
1750
- this action to. If None, a new chain is created. Defaults to None.
1751
-
1752
- Returns:
1753
- ActionChains: The ActionChains instance (either the one passed in or a new one)
1754
- with the scroll action added, allowing for method chaining.
1755
- """
1756
-
1757
- ...
1758
-
1759
- async def scroll_from_origin_action(
1760
- self,
1761
- origin: ScrollOrigin,
1762
- delta_x: int,
1763
- delta_y: int,
1764
- duration: int = 250,
1765
- action_chain: Optional[ActionChains] = None
1766
- ) -> ActionChains:
1767
- """
1768
- Adds a scroll action relative to a specified origin (viewport or element center).
1769
-
1770
- If an existing ActionChains object is provided via `action_chain`, this action
1771
- is appended to it. Otherwise, a new ActionChains object is created using
1772
- `self.build_action_chains` with the specified duration before adding the action.
1773
-
1774
- Args:
1775
- origin (ScrollOrigin): The origin point for the scroll. This object defines
1776
- whether the scroll is relative to the viewport or an element's center.
1777
- Use `ScrollOrigin.from_viewport()` or `ScrollOrigin.from_element()`.
1778
- delta_x (int): The horizontal scroll amount. Positive scrolls right, negative left.
1779
- delta_y (int): The vertical scroll amount. Positive scrolls down, negative up.
1780
- duration (int): The duration in milliseconds to use when creating a new
1781
- ActionChains instance if `action_chain` is None. Defaults to 250.
1782
- action_chain (Optional[ActionChains]): An existing ActionChains instance to append
1783
- this action to. If None, a new chain is created. Defaults to None.
1784
-
1785
- Returns:
1786
- ActionChains: The ActionChains instance (either the one passed in or a new one)
1787
- with the scroll action added, allowing for method chaining.
1788
- """
1789
-
1790
- ...
1791
-
1792
- async def scroll_to_element_action(
1793
- self,
1794
- element: WebElement,
1795
- duration: int = 250,
1796
- action_chain: Optional[ActionChains] = None
1797
- ) -> ActionChains:
1798
- """
1799
- Adds an action to scroll the viewport until the specified element is in view.
1800
-
1801
- If an existing ActionChains object is provided via `action_chain`, this action
1802
- is appended to it. Otherwise, a new ActionChains object is created using
1803
- `self.build_action_chains` with the specified duration before adding the action.
1804
-
1805
- Args:
1806
- element (WebElement): The target web element to scroll into view.
1807
- duration (int): The duration in milliseconds to use when creating a new
1808
- ActionChains instance if `action_chain` is None. Defaults to 250.
1809
- action_chain (Optional[ActionChains]): An existing ActionChains instance to append
1810
- this action to. If None, a new chain is created. Defaults to None.
1811
-
1812
- Returns:
1813
- ActionChains: The ActionChains instance (either the one passed in or a new one)
1814
- with the scroll-to-element action added, allowing for method chaining.
1815
- """
1816
-
1817
- ...
1818
-
1819
- async def search_url(
1820
- self,
1821
- url: str,
1822
- temp_implicitly_wait: Optional[int] = None,
1823
- temp_page_load_timeout: Optional[int] = None
1824
- ):
1825
- """
1826
- Opens a URL in the current browser session.
1827
-
1828
- Navigates the browser to a specified URL. This action loads the new webpage in the current browser window or tab.
1829
-
1830
- Args:
1831
- url (str): The URL to open. Must be a valid web address (e.g., "https://www.example.com").
1832
- temp_implicitly_wait (Optional[int]): Temporary implicit wait time in seconds for page load. Defaults to None.
1833
- temp_page_load_timeout (Optional[int]): Temporary page load timeout in seconds for page load. Defaults to None.
1834
- """
1835
-
1836
- ...
1837
-
1838
- async def send_keys_action(
1839
- self,
1840
- keys_to_send: str,
1841
- duration: int = 250,
1842
- action_chain: Optional[ActionChains] = None
1843
- ) -> ActionChains:
1844
- """
1845
- Adds a send keys action to the currently focused element.
1846
-
1847
- If an existing ActionChains object is provided via `action_chain`, this action
1848
- is appended to it. Otherwise, a new ActionChains object is created using
1849
- `self.build_action_chains` with the specified duration before adding the action.
1850
-
1851
- Args:
1852
- keys_to_send (str): The sequence of keys to send.
1853
- duration (int): The duration in milliseconds to use when creating a new
1854
- ActionChains instance if `action_chain` is None. Defaults to 250.
1855
- action_chain (Optional[ActionChains]): An existing ActionChains instance to append
1856
- this action to. If None, a new chain is created. Defaults to None.
1857
-
1858
- Returns:
1859
- ActionChains: The ActionChains instance (either the one passed in or a new one)
1860
- with the send keys action added, allowing for method chaining.
1861
- """
1862
-
1863
- ...
1864
-
1865
- async def send_keys_to_element_action(
1866
- self,
1867
- element: WebElement,
1868
- keys_to_send: str,
1869
- duration: int = 250,
1870
- action_chain: Optional[ActionChains] = None
1871
- ) -> ActionChains:
1872
- """
1873
- Adds a send keys action specifically to the provided web element.
1874
-
1875
- If an existing ActionChains object is provided via `action_chain`, this action
1876
- is appended to it. Otherwise, a new ActionChains object is created using
1877
- `self.build_action_chains` with the specified duration before adding the action.
1878
-
1879
- Args:
1880
- element (WebElement): The target web element to send keys to.
1881
- keys_to_send (str): The sequence of keys to send.
1882
- duration (int): The duration in milliseconds to use when creating a new
1883
- ActionChains instance if `action_chain` is None. Defaults to 250.
1884
- action_chain (Optional[ActionChains]): An existing ActionChains instance to append
1885
- this action to. If None, a new chain is created. Defaults to None.
1886
-
1887
- Returns:
1888
- ActionChains: The ActionChains instance (either the one passed in or a new one)
1889
- with the send keys to element action added, allowing for method chaining.
1890
- """
1891
-
1892
- ...
1893
-
1894
- async def set_captcha_worker(self, captcha_worker: "CaptchaWorkerSettings"):
1895
- """
1896
- Adds a captcha worker configuration to the list of workers.
1897
-
1898
- Args:
1899
- captcha_worker ("CaptchaWorkerSettings"): The captcha worker settings to add.
1900
- """
1901
-
1902
- ...
1903
-
1904
- async def set_driver_timeouts(
1905
- self,
1906
- page_load_timeout: float,
1907
- implicit_wait_timeout: float,
1908
- script_timeout: float,
1909
- ):
1910
- """
1911
- Sets all three WebDriver timeouts: page load, implicit wait, and script timeout.
1912
-
1913
- Args:
1914
- page_load_timeout (float): The page load timeout in seconds.
1915
- implicit_wait_timeout (float): The implicit wait timeout in seconds.
1916
- script_timeout (float): The asynchronous script timeout in seconds.
1917
- """
1918
-
1919
- ...
1920
-
1921
- async def set_implicitly_wait_timeout(self, implicitly_wait_timeout: float):
1922
- """
1923
- Sets the implicit wait timeout for WebDriver element searches.
1924
-
1925
- Configures the implicit wait time, which is the maximum time WebDriver will wait
1926
- when searching for elements before throwing a `NoSuchElementException`. This setting
1927
- applies globally to all element searches for the duration of the WebDriver session.
1928
-
1929
- Args:
1930
- implicitly_wait_timeout (float): The implicit wait timeout value in seconds.
1931
- """
1932
-
1933
- ...
1934
-
1935
- async def set_page_load_timeout(self, page_load_timeout: float):
1936
- """
1937
- Sets the page load timeout for WebDriver operations.
1938
-
1939
- Defines the maximum time WebDriver will wait for a page to fully load before timing out
1940
- and throwing a `TimeoutException`. This is useful to prevent tests from hanging indefinitely
1941
- on slow-loading pages.
1942
-
1943
- Args:
1944
- page_load_timeout (float): The page load timeout value in seconds.
1945
- """
1946
-
1947
- ...
1948
-
1949
- async def set_script_timeout(self, script_timeout: float):
1950
- """
1951
- Sets the asynchronous script timeout for WebDriver operations.
1952
-
1953
- Configures the maximum time WebDriver will wait for an asynchronous JavaScript
1954
- script to complete its execution before timing out.
1955
-
1956
- Args:
1957
- script_timeout (float): The asynchronous script timeout value in seconds.
1958
- """
1959
-
1960
- ...
1961
-
1962
- async def set_trio_tokens_limit(self, trio_tokens_limit: Union[int, float]):
1963
- """
1964
- Updates the total number of tokens for the Trio capacity limiter.
1965
-
1966
- Args:
1967
- trio_tokens_limit (Union[int, float]): The new total token limit. Use math.inf for unlimited.
1968
- """
1969
-
1970
- ...
1971
-
1972
- async def set_user_verified(self, verified: bool):
1973
- """
1974
- Sets the user verification state for WebAuthn.
1975
-
1976
- This is typically used with virtual authenticators to simulate user verification.
1977
-
1978
- Args:
1979
- verified (bool): True to set the user as verified, False otherwise.
1980
- """
1981
-
1982
- ...
1983
-
1984
- async def set_window_rect(self, rect: WindowRect):
1985
- """
1986
- Sets the browser window rectangle.
1987
-
1988
- Adjusts the position and size of the browser window to the specified rectangle. This can be used
1989
- to manage window placement and dimensions for testing or display purposes.
1990
-
1991
- Args:
1992
- rect (WindowRect): An object containing the desired window rectangle parameters (x, y, width, height).
1993
- """
1994
-
1995
- ...
1996
-
1997
- async def start_webdriver(
1998
- self,
1999
- flags: Optional[Union["BrowserFlags", _any_flags_mapping]] = None,
2000
- window_rect: Optional[WindowRect] = None,
2001
- trio_tokens_limit: Optional[Union[int, float]] = None,
2002
- ):
2003
- """
2004
- Starts the WebDriver service and the browser session.
2005
-
2006
- Initializes and starts the WebDriver instance and the associated browser process.
2007
- It first updates settings based on provided parameters (if the driver is not already running),
2008
- and then creates the WebDriver client instance (`self.driver`).
2009
-
2010
- Args:
2011
- flags (Optional[Union["BrowserFlags", _any_flags_mapping]]): Override flags for this start. Defaults to None (use current settings).
2012
- window_rect (Optional[WindowRect]): Override window rectangle for this start. Defaults to None (use current setting).
2013
- trio_tokens_limit (Optional[Union[int, float]]): Override Trio token limit for this start. Defaults to None (use current setting).
2014
- """
2015
-
2016
- ...
2017
-
2018
- async def stop_window_loading(self):
2019
- """
2020
- Stops the current page loading.
2021
-
2022
- Interrupts the loading process of the current webpage. This can be useful when a page is taking too long
2023
- to load or when you want to halt resource loading for performance testing or specific scenarios.
2024
- """
2025
-
2026
- ...
2027
-
2028
- @property
2029
- def supports_fedcm(self) -> bool:
2030
- """
2031
- Checks if the browser supports the Federated Credential Management (FedCM) API.
2032
-
2033
- Returns:
2034
- bool: True if FedCM is supported, False otherwise.
2035
- """
2036
-
2037
- ...
2038
-
2039
- async def switch_to_frame(self, frame: Union[str, int, WebElement]):
2040
- """
2041
- Switches the driver's focus to a frame.
2042
-
2043
- Changes the WebDriver's focus to a specific frame within the current page. Frames are often used to embed
2044
- content from other sources within a webpage. After switching to a frame, all WebDriver commands will be
2045
- directed to elements within that frame until focus is switched back.
2046
-
2047
- Args:
2048
- frame (Union[str, int, WebElement]): Specifies the frame to switch to. Can be a frame name (str), index (int), or a WebElement representing the frame.
2049
- """
2050
-
2051
- ...
2052
-
2053
- async def switch_to_window(self, window: Optional[Union[str, int]] = None):
2054
- """
2055
- Switches the driver's focus to the specified browser window.
2056
-
2057
- Uses get_window_handle to resolve the target window identifier (handle string or index)
2058
- before instructing the driver to switch. If no window identifier is provided,
2059
- it effectively switches to the current window.
2060
-
2061
- Args:
2062
- window (Optional[Union[str, int]]): The identifier of the window to switch to.
2063
- Can be a window handle (string) or an index (int) in the list of window handles.
2064
- If None, targets the current window handle.
2065
- """
2066
-
2067
- ...
2068
-
2069
- async def update_settings(
2070
- self,
2071
- flags: Optional[Union["BrowserFlags", _any_flags_mapping]] = None,
2072
- window_rect: Optional[WindowRect] = None,
2073
- trio_tokens_limit: Optional[Union[int, float]] = None,
2074
- ):
2075
- """
2076
- Updates various browser settings after initialization or selectively.
2077
-
2078
- This method allows for dynamic updating of browser settings. Only the settings
2079
- provided (not None) will be updated.
2080
-
2081
- Args:
2082
- flags (Optional[Union["BrowserFlags", _any_flags_mapping]]): A dictionary of flags to update. Existing flags will be overwritten, others remain.
2083
- window_rect (Optional[WindowRect]): Update the window rectangle settings. Defaults to None (no change).
2084
- trio_tokens_limit (Optional[Union[int, float]]): Update the Trio token limit. Defaults to None (no change).
2085
- """
2086
-
2087
- ...
2088
-
2089
- async def update_times(
2090
- self,
2091
- temp_implicitly_wait: Optional[float] = None,
2092
- temp_page_load_timeout: Optional[float] = None,
2093
- temp_script_timeout: Optional[float] = None,
2094
- ):
2095
- """
2096
- Updates the WebDriver's timeout settings, adding a small random delay for human-like behavior.
2097
-
2098
- If temporary timeouts are provided, they are used; otherwise, the base timeouts are used.
2099
- A random float between 0 and 1 is added to each timeout to simulate variability.
2100
-
2101
- Args:
2102
- temp_implicitly_wait (Optional[float]): Temporary implicit wait time in seconds.
2103
- If provided, overrides the base implicit wait for this update. Defaults to None.
2104
- temp_page_load_timeout (Optional[float]): Temporary page load timeout in seconds.
2105
- If provided, overrides the base page load timeout for this update. Defaults to None.
2106
- temp_script_timeout (Optional[float]): Temporary asynchronous script timeout in seconds.
2107
- If provided, overrides the base script timeout for this update. Defaults to None.
2108
- """
2109
-
2110
- ...
2111
-
2112
- @property
2113
- def virtual_authenticator_id(self) -> Optional[str]:
2114
- """
2115
- Gets the ID of the active virtual authenticator.
2116
-
2117
- Returns:
2118
- Optional[str]: The ID of the virtual authenticator if one is active, otherwise None.
2119
- """
2120
-
2121
- ...
2122
-
2123
- @property
2124
- def windows_handles(self) -> list[str]:
2125
- """
2126
- Gets the handles of all open windows.
2127
-
2128
- Returns a list of handles for all browser windows or tabs currently open and managed by the WebDriver.
2129
- This is useful for iterating through or managing multiple windows in a browser session.
2130
-
2131
- Returns:
2132
- list[str]: A list of window handles. Each handle is a string identifier for an open window.
2133
- """
2134
-
2135
- ...