Skip to content

Commit 8242d5e

Browse files
switch to frame
1 parent e6f491a commit 8242d5e

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/session/extra.lua

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,29 @@ PublicSession.get_current_url = function(public, private)
3636
return body.value
3737
end
3838

39+
-- Troca para um frame específico usando um elemento frame
40+
PublicSession.switch_to_frame = function(public, private, element_frame)
41+
if not element_frame then
42+
error("element_frame is required to switch to frame")
43+
end
44+
45+
local frame_id = element_frame.get_chromedriver_id()
46+
47+
local result = private.fetch({
48+
url = private.url .. "/session/" .. private.session_id .. "/frame",
49+
method = "POST",
50+
http_version = "1.1",
51+
body = {
52+
id = {
53+
["element-6066-11e4-a52e-4f735466cecf"] = frame_id
54+
}
55+
}
56+
})
57+
58+
if result.status_code ~= 200 then
59+
error("Failed to switch to frame: " .. result.read_body())
60+
end
61+
62+
return true
63+
end
64+

0 commit comments

Comments
 (0)