2023-05-13 15:57:03 +02:00
|
|
|
open Utils
|
|
|
|
|
2023-05-15 11:44:21 +02:00
|
|
|
let empty = "{}"
|
|
|
|
|
2023-05-13 22:13:26 +02:00
|
|
|
let connection_payload headless =
|
|
|
|
fmt
|
|
|
|
{|
|
2023-05-13 10:40:03 +02:00
|
|
|
{
|
|
|
|
"capabilities": {
|
|
|
|
"alwaysMatch": {
|
|
|
|
"moz:firefoxOptions": {
|
2023-05-13 22:13:26 +02:00
|
|
|
"args": [%s]
|
2023-05-13 10:40:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-03-09 16:08:41 +01:00
|
|
|
|}
|
2023-05-13 22:13:26 +02:00
|
|
|
(if headless then "\"-headless\"" else "")
|
2023-05-13 10:40:03 +02:00
|
|
|
;;
|
2023-05-13 15:57:03 +02:00
|
|
|
|
|
|
|
let navigate_payload url = fmt {|
|
|
|
|
{
|
|
|
|
"url": "%s"
|
|
|
|
}
|
2024-03-09 16:08:41 +01:00
|
|
|
|} url
|
2023-05-13 17:10:19 +02:00
|
|
|
|
|
|
|
let execute_payload src = fmt {|
|
|
|
|
{
|
|
|
|
"script": "%s",
|
|
|
|
"args": []
|
|
|
|
}
|
2024-03-09 16:08:41 +01:00
|
|
|
|} src
|
2023-05-13 20:31:46 +02:00
|
|
|
|
|
|
|
let find_payload strategy value =
|
|
|
|
fmt {|
|
|
|
|
{
|
|
|
|
"using": "%s",
|
|
|
|
"value": "%s"
|
|
|
|
}
|
2024-03-09 16:08:41 +01:00
|
|
|
|} strategy value
|
2023-05-13 20:31:46 +02:00
|
|
|
;;
|
2023-05-13 22:13:26 +02:00
|
|
|
|
|
|
|
let send_keys_payload text =
|
|
|
|
fmt
|
|
|
|
{|
|
|
|
|
{
|
|
|
|
"text": "%s",
|
|
|
|
"value": %s
|
|
|
|
}
|
2024-03-09 16:08:41 +01:00
|
|
|
|}
|
2023-05-13 22:13:26 +02:00
|
|
|
text
|
|
|
|
(Yojson.Safe.to_string
|
|
|
|
(`List (List.map (fun str -> `String str) (keys_to_typing text))))
|
|
|
|
;;
|
2024-03-09 16:13:52 +01:00
|
|
|
|
|
|
|
let send_left_click pos_x pos_y =
|
|
|
|
fmt
|
|
|
|
{|
|
|
|
|
{
|
|
|
|
"actions": [
|
|
|
|
{
|
|
|
|
"type": "pointer",
|
|
|
|
"id": "mouse",
|
|
|
|
"parameters": {
|
|
|
|
"pointerType": "mouse"
|
|
|
|
},
|
|
|
|
"actions": [
|
|
|
|
{
|
|
|
|
"type": "pointerMove",
|
|
|
|
"origin": "viewport",
|
|
|
|
"x": %d,
|
|
|
|
"y": %d,
|
|
|
|
"duration": 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "pointerDown",
|
|
|
|
"button": 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "pause",
|
|
|
|
"duration": 100
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "pointerUp",
|
|
|
|
"button": 0
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|}
|
|
|
|
pos_x
|
|
|
|
pos_y
|
|
|
|
;;
|