File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,38 @@ PublicSession.close = function (public, private)
1818 private .closed = true
1919end
2020
21+
22+
23+ -- Add this function to PublicSession
24+ PublicSession .execute_cdp_cmd = function (public , private , cmd , params )
25+ if not cmd or type (cmd ) ~= " string" then
26+ error (" CDP command must be a non-empty string" )
27+ end
28+
29+ -- Default to empty params if not provided
30+ if not params then
31+ params = {}
32+ end
33+
34+ local result = private .fetch ({
35+ url = private .url .. " /session/" .. private .session_id .. " /goog/cdp/execute" ,
36+ method = " POST" ,
37+ http_version = " 1.1" ,
38+ body = {
39+ cmd = cmd ,
40+ params = params
41+ }
42+ })
43+
44+ if result .status_code ~= 200 then
45+ local error_body = result .read_body ()
46+ error (" Failed to execute CDP command '" .. cmd .. " ': " .. (error_body or " Unknown error" ))
47+ end
48+
49+ local body = result .read_body_json ()
50+ return body .value
51+ end
52+
2153-- Retorna a quantidade de abas (janelas) abertas na sessão
2254PublicSession .get_window_count = function (public , private )
2355 local result = private .fetch ({
You can’t perform that action at this time.
0 commit comments