Skip to content

Commit 718103e

Browse files
att
1 parent defe14c commit 718103e

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

src/element/retrivers.lua

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ PublicElement.get_attribute = function(public, private, attribute_name)
5656
end
5757

5858

59-
60-
61-
PublicElement.execute_script = function(public, private, script, ...)
59+
PublicElement.get_requisition_props = function(public, private, script, ...)
6260
if not script or type(script) ~= "string" then
6361
error("Script should be a non-empty string")
6462
end
@@ -68,7 +66,7 @@ PublicElement.execute_script = function(public, private, script, ...)
6866
-- Insert the element reference as the first argument (arguments[0] in JavaScript)
6967
local element_ref = {["element-6066-11e4-a52e-4f735466cecf"] = private.element_id}
7068
table.insert(args, 1, element_ref)
71-
local requisition_props = {
69+
return {
7270
method = "POST",
7371
http_version = "1.1",
7472
url = private.url .. "/session/" .. private.session_id .. "/execute/sync",
@@ -77,6 +75,10 @@ PublicElement.execute_script = function(public, private, script, ...)
7775
args = args
7876
}
7977
}
78+
end
79+
80+
PublicElement.execute_script = function(public, private, script, ...)
81+
local requisition_props = public.get_requisition_props(script, ...)
8082
local response = private.fetch(requisition_props)
8183

8284
if response.status_code == 200 then

src/server.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11

22
Server.__gc = function (public,private)
33
print("turning off chromedriver on port " .. private.port)
4+
45
private.fetch({
56
http_version = "1.1",
67
url=string.format("http://127.0.0.1:%d/shutdown", private.port),
78
})
9+
810
end
911

1012
Server.newSession = function(public,private, props)
@@ -15,7 +17,9 @@ Server.newSession = function(public,private, props)
1517
error("binary_location is required")
1618
end
1719

18-
return Session.newSession({url = private.url, fetch = private.fetch,binary_location= props.binary_location,args=props.args})
20+
local created = Session.newSession(private,{binary_location= props.binary_location,args=props.args})
21+
created.server = public
22+
return created
1923
end
2024

2125

src/session/constructor.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33

44

5-
Session.newSession = function (props)
5+
Session.newSession = function (private_server_props,props)
66

77
local selfobject = Heregitage.newMetaObject()
8+
selfobject.private_props_extends(private_server_props)
89
selfobject.private_props_extends(props)
910
selfobject.meta_method_extends(MetaSession)
1011
selfobject.public_method_extends(PublicSession)
@@ -27,8 +28,8 @@ Session.newSession = function (props)
2728

2829
local use_automation_extension = props.use_automation_extension or false
2930

30-
local result = props.fetch({
31-
url=props.url.."/session",
31+
local result = selfobject.private.fetch({
32+
url=selfobject.private.url.."/session",
3233
method = "POST",
3334
http_version = "1.1",
3435
body = {

0 commit comments

Comments
 (0)