@@ -9,47 +9,65 @@ Session.newSession = function (private_server_props,props)
99 selfobject .private_props_extends (props )
1010 selfobject .meta_method_extends (MetaSession )
1111 selfobject .public_method_extends (PublicSession )
12- local args = props .args
13- if not args then
14- args = {
15- " --disable-blink-features=AutomationControlled" ,
16- " --disable-infobars" ,
17- " --disable-notifications" ,
18- " --disable-popup-blocking" ,
19- " --disable-extensions" ,
20- " --no-sandbox" ,
21- " --ignore-certificate-errors" ,
22- " --window-size=1920,1080" ,
23- " --user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"
24- }
25- end
26-
27- local use_automation_extension = props .use_automation_extension or false
28-
29- local result = selfobject .private .fetch ({
30- url = selfobject .private .url .. " /session" ,
31- method = " POST" ,
32- http_version = " 1.1" ,
33- body = {
34- capabilities = {
35- alwaysMatch = {
36- browserName = " chrome" ,
37- [" goog:chromeOptions" ] = {
38- binary = props .binary_location ,
39- args = args ,
40- prefs = {
41- [" download.default_directory" ]= props .download_directory
42- },
43- excludeSwitches = {" enable-automation" },
44- useAutomationExtension = use_automation_extension
12+
13+
14+
15+
16+
17+ local requisition = props .requisition
18+ if not requisition then
19+
20+ local args = props .args
21+ if not args then
22+ args = {
23+ " --disable-blink-features=AutomationControlled" ,
24+ " --disable-infobars" ,
25+ " --disable-notifications" ,
26+ " --disable-popup-blocking" ,
27+ " --disable-extensions" ,
28+ " --no-sandbox" ,
29+ " --ignore-certificate-errors" ,
30+ " --window-size=1920,1080" ,
31+ " --user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"
32+ }
33+ end
34+
35+ local use_automation_extension = props .use_automation_extension or false
36+ requisition = {
37+ method = " POST" ,
38+ http_version = " 1.1" ,
39+ body = {
40+ capabilities = {
41+ alwaysMatch = {
42+ browserName = " chrome" ,
43+ [" goog:chromeOptions" ] = {
44+ binary = props .binary_location ,
45+ args = args ,
46+ prefs = {
47+ [" download.default_directory" ]= props .download_directory
48+ },
49+ excludeSwitches = {" enable-automation" },
50+ useAutomationExtension = use_automation_extension
51+ }
4552 }
4653 }
4754 }
4855 }
49- })
56+ end
57+ requisition .url = selfobject .private .url .. " /session"
58+
59+
60+
61+ local result = selfobject .private .fetch (requisition )
62+
63+
5064 local body = result .read_body_json ()
51- print (json .dumps_to_string (body ))
5265 selfobject .private .session_id = body .value .sessionId
66+
67+ if not selfobject .private .session_id then
68+ error (json .dumps_to_string (body ))
69+ end
70+
5371 return selfobject .public
5472
5573end
0 commit comments