pusk/lib/json.ml

55 lines
743 B
OCaml
Raw Normal View History

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
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))))
;;