patchright-cli 0.3.0__py3-none-any.whl → 0.4.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.
- patchright_cli/__init__.py +1 -1
- patchright_cli/cli.py +26 -20
- patchright_cli/daemon.py +988 -614
- patchright_cli/ref_registry.py +74 -0
- patchright_cli/snapshot.py +21 -321
- {patchright_cli-0.3.0.dist-info → patchright_cli-0.4.0.dist-info}/METADATA +1 -1
- patchright_cli-0.4.0.dist-info/RECORD +11 -0
- patchright_cli-0.3.0.dist-info/RECORD +0 -10
- {patchright_cli-0.3.0.dist-info → patchright_cli-0.4.0.dist-info}/WHEEL +0 -0
- {patchright_cli-0.3.0.dist-info → patchright_cli-0.4.0.dist-info}/entry_points.txt +0 -0
- {patchright_cli-0.3.0.dist-info → patchright_cli-0.4.0.dist-info}/licenses/LICENSE +0 -0
patchright_cli/__init__.py
CHANGED
patchright_cli/cli.py
CHANGED
|
@@ -72,6 +72,7 @@ COMMANDS_HELP = {
|
|
|
72
72
|
"uncheck": "uncheck <ref> Uncheck checkbox/radio",
|
|
73
73
|
"snapshot": "snapshot [ref] Take accessibility snapshot",
|
|
74
74
|
"eval": "eval <expr> Evaluate JavaScript [--file=F or stdin]",
|
|
75
|
+
"text": "text <ref|selector> Get text content of element",
|
|
75
76
|
"screenshot": "screenshot [ref] Save screenshot [--full-page] [--filename=F]",
|
|
76
77
|
"drag": "drag <from> <to> Drag element to target",
|
|
77
78
|
"close": "close Close browser session",
|
|
@@ -79,6 +80,8 @@ COMMANDS_HELP = {
|
|
|
79
80
|
"go-back": "go-back Go back",
|
|
80
81
|
"go-forward": "go-forward Go forward",
|
|
81
82
|
"reload": "reload Reload page",
|
|
83
|
+
"url": "url Print current URL",
|
|
84
|
+
"title": "title Print page title",
|
|
82
85
|
# Keyboard
|
|
83
86
|
"press": "press <key> Press key",
|
|
84
87
|
"keydown": "keydown <key> Key down",
|
|
@@ -88,6 +91,11 @@ COMMANDS_HELP = {
|
|
|
88
91
|
"mousedown": "mousedown [button] Mouse button down",
|
|
89
92
|
"mouseup": "mouseup [button] Mouse button up",
|
|
90
93
|
"mousewheel": "mousewheel <dx> <dy> Scroll mouse wheel",
|
|
94
|
+
# Scroll & Wait
|
|
95
|
+
"scroll": "scroll <dx> <dy> Scroll by pixel offset",
|
|
96
|
+
"scroll-to": "scroll-to <ref> Scroll element into view",
|
|
97
|
+
"wait": "wait <ms> Wait for milliseconds",
|
|
98
|
+
"wait-for": "wait-for <ref> Wait for element to appear [--state=hidden]",
|
|
91
99
|
# Tabs
|
|
92
100
|
"tab-list": "tab-list List tabs",
|
|
93
101
|
"tab-new": "tab-new [url] Open new tab",
|
|
@@ -99,6 +107,8 @@ COMMANDS_HELP = {
|
|
|
99
107
|
"cookie-set": "cookie-set <n> <v> Set cookie [--domain --path --expires --httpOnly --secure --sameSite]",
|
|
100
108
|
"cookie-delete": "cookie-delete <name> Delete cookie",
|
|
101
109
|
"cookie-clear": "cookie-clear Clear all cookies",
|
|
110
|
+
"cookie-import": "cookie-import <file> Import cookies from JSON",
|
|
111
|
+
"cookie-export": "cookie-export [file] Export cookies to JSON",
|
|
102
112
|
"localstorage-list": "localstorage-list List localStorage",
|
|
103
113
|
"localstorage-get": "localstorage-get <k> Get localStorage item",
|
|
104
114
|
"localstorage-set": "localstorage-set <k> <v> Set localStorage item",
|
|
@@ -154,6 +164,7 @@ def _print_help():
|
|
|
154
164
|
click.echo(" --headless Run headless (default: headed)")
|
|
155
165
|
click.echo(" --persistent Use persistent profile")
|
|
156
166
|
click.echo(" --profile=<path> Custom profile directory")
|
|
167
|
+
click.echo(" --proxy=<url> Proxy server (e.g. http://host:port, socks5://host:port)")
|
|
157
168
|
click.echo(" -s=<name> Named session (default: 'default')")
|
|
158
169
|
click.echo(" --port=<n> Daemon port (default: 9321)")
|
|
159
170
|
click.echo(" --version Show version")
|
|
@@ -176,14 +187,16 @@ def _print_help():
|
|
|
176
187
|
"uncheck",
|
|
177
188
|
"snapshot",
|
|
178
189
|
"eval",
|
|
190
|
+
"text",
|
|
179
191
|
"screenshot",
|
|
180
192
|
"drag",
|
|
181
193
|
"close",
|
|
182
194
|
],
|
|
183
195
|
),
|
|
184
|
-
("Navigation", ["go-back", "go-forward", "reload"]),
|
|
196
|
+
("Navigation", ["go-back", "go-forward", "reload", "url", "title"]),
|
|
185
197
|
("Keyboard", ["press", "keydown", "keyup"]),
|
|
186
198
|
("Mouse", ["mousemove", "mousedown", "mouseup", "mousewheel"]),
|
|
199
|
+
("Scroll & Wait", ["scroll", "scroll-to", "wait", "wait-for"]),
|
|
187
200
|
("Tabs", ["tab-list", "tab-new", "tab-close", "tab-select"]),
|
|
188
201
|
("Dialog", ["dialog-accept", "dialog-dismiss"]),
|
|
189
202
|
("Upload/Resize", ["upload", "resize"]),
|
|
@@ -196,6 +209,8 @@ def _print_help():
|
|
|
196
209
|
"cookie-set",
|
|
197
210
|
"cookie-delete",
|
|
198
211
|
"cookie-clear",
|
|
212
|
+
"cookie-import",
|
|
213
|
+
"cookie-export",
|
|
199
214
|
"localstorage-list",
|
|
200
215
|
"localstorage-get",
|
|
201
216
|
"localstorage-set",
|
|
@@ -231,6 +246,7 @@ def main():
|
|
|
231
246
|
headless = False
|
|
232
247
|
persistent = False
|
|
233
248
|
profile = None
|
|
249
|
+
proxy = None
|
|
234
250
|
session_name = "default"
|
|
235
251
|
port = DEFAULT_PORT
|
|
236
252
|
|
|
@@ -248,6 +264,11 @@ def main():
|
|
|
248
264
|
elif arg == "--profile" and i + 1 < len(argv):
|
|
249
265
|
i += 1
|
|
250
266
|
profile = argv[i]
|
|
267
|
+
elif arg.startswith("--proxy="):
|
|
268
|
+
proxy = arg.split("=", 1)[1]
|
|
269
|
+
elif arg == "--proxy" and i + 1 < len(argv):
|
|
270
|
+
i += 1
|
|
271
|
+
proxy = argv[i]
|
|
251
272
|
elif arg.startswith("-s="):
|
|
252
273
|
session_name = arg.split("=", 1)[1]
|
|
253
274
|
elif arg == "-s" and i + 1 < len(argv):
|
|
@@ -330,27 +351,12 @@ def main():
|
|
|
330
351
|
options["persistent"] = True
|
|
331
352
|
if profile:
|
|
332
353
|
options["profile"] = profile
|
|
354
|
+
if proxy:
|
|
355
|
+
options["proxy"] = proxy
|
|
333
356
|
|
|
334
|
-
# Ensure daemon is running (auto-start for
|
|
357
|
+
# Ensure daemon is running (auto-start for all commands)
|
|
335
358
|
try:
|
|
336
|
-
|
|
337
|
-
ensure_daemon_running(port, headless)
|
|
338
|
-
else:
|
|
339
|
-
# Try connecting first; if fails, tell user to open
|
|
340
|
-
import socket as _socket
|
|
341
|
-
|
|
342
|
-
sock = _socket.socket(_socket.AF_INET, _socket.SOCK_STREAM)
|
|
343
|
-
try:
|
|
344
|
-
sock.settimeout(1)
|
|
345
|
-
sock.connect(("127.0.0.1", port))
|
|
346
|
-
except (ConnectionRefusedError, OSError, TimeoutError):
|
|
347
|
-
click.echo(
|
|
348
|
-
f"Daemon is not running on port {port}. Run 'patchright-cli open' first.",
|
|
349
|
-
err=True,
|
|
350
|
-
)
|
|
351
|
-
sys.exit(1)
|
|
352
|
-
finally:
|
|
353
|
-
sock.close()
|
|
359
|
+
ensure_daemon_running(port, headless)
|
|
354
360
|
except RuntimeError as e:
|
|
355
361
|
click.echo(str(e), err=True)
|
|
356
362
|
sys.exit(1)
|