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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|}
|
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"
|
|
|
|
}
|
|
|
|
|} url
|
2023-05-13 17:10:19 +02:00
|
|
|
|
|
|
|
let execute_payload src = fmt {|
|
|
|
|
{
|
|
|
|
"script": "%s",
|
|
|
|
"args": []
|
|
|
|
}
|
|
|
|
|} src
|
2023-05-13 20:31:46 +02:00
|
|
|
|
|
|
|
let find_payload strategy value =
|
|
|
|
fmt {|
|
|
|
|
{
|
|
|
|
"using": "%s",
|
|
|
|
"value": "%s"
|
|
|
|
}
|
|
|
|
|} strategy value
|
|
|
|
;;
|
2023-05-13 22:13:26 +02:00
|
|
|
|
|
|
|
let send_keys_payload text =
|
|
|
|
fmt
|
|
|
|
{|
|
|
|
|
{
|
|
|
|
"text": "%s",
|
|
|
|
"value": %s
|
|
|
|
}
|
|
|
|
|}
|
|
|
|
text
|
|
|
|
(Yojson.Safe.to_string
|
|
|
|
(`List (List.map (fun str -> `String str) (keys_to_typing text))))
|
|
|
|
;;
|