since tweet issue (#3)
All checks were successful
ci/woodpecker/push/publish Pipeline was successful

This commit is contained in:
Mylloon 2024-03-09 16:13:52 +01:00
parent cc94b15e01
commit 9d0e2f6a7f
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
3 changed files with 50 additions and 0 deletions

View file

@ -151,6 +151,9 @@ let tweet ctx msg =
| it :: [] -> it
| _ -> raise (Any "Too many tweet button found")
in
(* We need first to click somewhere on the page to be able to interact with it *)
click_somewhere ctx.session_id 800 200;
Unix.sleep 2;
click ctx.session_id send_tweet_button;
Unix.sleep 8
;;

View file

@ -52,3 +52,43 @@ let send_keys_payload text =
(Yojson.Safe.to_string
(`List (List.map (fun str -> `String str) (keys_to_typing text))))
;;
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
;;

View file

@ -153,6 +153,13 @@ let click session_id element_id =
Json.empty)
;;
let click_somewhere session_id x y =
ignore
(execute_post_request
(fmt "%s/actions" (driver session_id))
(Json.send_left_click x y))
;;
let get_attribute session_id element_id attribute =
let response =
execute_get_request