Skip to content

Commit 9bf146c

Browse files
att
1 parent 1324d01 commit 9bf146c

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/element/actions.lua

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
PublicElement.send_keys = function(public, private, keys)
32
-- Check if the keys parameter is a string
43
if type(keys) ~= "string" then
@@ -24,6 +23,23 @@ PublicElement.send_keys = function(public, private, keys)
2423
return true
2524
end
2625

26+
PublicElement.clear = function(public, private)
27+
-- Send a POST request to clear the element's value
28+
local result = private.fetch({
29+
url = private.url .. "/session/" .. private.session_id .. "/element/" .. private.element_id .. "/clear",
30+
method = "POST",
31+
http_version = "1.1",
32+
body = {}
33+
})
34+
35+
-- Check for errors in the response
36+
if result.status_code ~= 200 then
37+
error("Failed to clear element: " .. (result.read_body() or "Unknown error"))
38+
end
39+
40+
return true
41+
end
42+
2743
PublicElement.click = function(public, private)
2844
-- Send a POST request to click the element
2945
local result = private.fetch({

0 commit comments

Comments
 (0)