patchright-cli 0.3.1__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 +17 -20
- patchright_cli/daemon.py +977 -609
- patchright_cli/ref_registry.py +74 -0
- patchright_cli/snapshot.py +21 -321
- {patchright_cli-0.3.1.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.1.dist-info/RECORD +0 -10
- {patchright_cli-0.3.1.dist-info → patchright_cli-0.4.0.dist-info}/WHEEL +0 -0
- {patchright_cli-0.3.1.dist-info → patchright_cli-0.4.0.dist-info}/entry_points.txt +0 -0
- {patchright_cli-0.3.1.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",
|
|
@@ -177,14 +187,16 @@ def _print_help():
|
|
|
177
187
|
"uncheck",
|
|
178
188
|
"snapshot",
|
|
179
189
|
"eval",
|
|
190
|
+
"text",
|
|
180
191
|
"screenshot",
|
|
181
192
|
"drag",
|
|
182
193
|
"close",
|
|
183
194
|
],
|
|
184
195
|
),
|
|
185
|
-
("Navigation", ["go-back", "go-forward", "reload"]),
|
|
196
|
+
("Navigation", ["go-back", "go-forward", "reload", "url", "title"]),
|
|
186
197
|
("Keyboard", ["press", "keydown", "keyup"]),
|
|
187
198
|
("Mouse", ["mousemove", "mousedown", "mouseup", "mousewheel"]),
|
|
199
|
+
("Scroll & Wait", ["scroll", "scroll-to", "wait", "wait-for"]),
|
|
188
200
|
("Tabs", ["tab-list", "tab-new", "tab-close", "tab-select"]),
|
|
189
201
|
("Dialog", ["dialog-accept", "dialog-dismiss"]),
|
|
190
202
|
("Upload/Resize", ["upload", "resize"]),
|
|
@@ -197,6 +209,8 @@ def _print_help():
|
|
|
197
209
|
"cookie-set",
|
|
198
210
|
"cookie-delete",
|
|
199
211
|
"cookie-clear",
|
|
212
|
+
"cookie-import",
|
|
213
|
+
"cookie-export",
|
|
200
214
|
"localstorage-list",
|
|
201
215
|
"localstorage-get",
|
|
202
216
|
"localstorage-set",
|
|
@@ -340,26 +354,9 @@ def main():
|
|
|
340
354
|
if proxy:
|
|
341
355
|
options["proxy"] = proxy
|
|
342
356
|
|
|
343
|
-
# Ensure daemon is running (auto-start for
|
|
357
|
+
# Ensure daemon is running (auto-start for all commands)
|
|
344
358
|
try:
|
|
345
|
-
|
|
346
|
-
ensure_daemon_running(port, headless)
|
|
347
|
-
else:
|
|
348
|
-
# Try connecting first; if fails, tell user to open
|
|
349
|
-
import socket as _socket
|
|
350
|
-
|
|
351
|
-
sock = _socket.socket(_socket.AF_INET, _socket.SOCK_STREAM)
|
|
352
|
-
try:
|
|
353
|
-
sock.settimeout(1)
|
|
354
|
-
sock.connect(("127.0.0.1", port))
|
|
355
|
-
except (ConnectionRefusedError, OSError, TimeoutError):
|
|
356
|
-
click.echo(
|
|
357
|
-
f"Daemon is not running on port {port}. Run 'patchright-cli open' first.",
|
|
358
|
-
err=True,
|
|
359
|
-
)
|
|
360
|
-
sys.exit(1)
|
|
361
|
-
finally:
|
|
362
|
-
sock.close()
|
|
359
|
+
ensure_daemon_running(port, headless)
|
|
363
360
|
except RuntimeError as e:
|
|
364
361
|
click.echo(str(e), err=True)
|
|
365
362
|
sys.exit(1)
|