since tweet issue (#3)
All checks were successful
ci/woodpecker/push/publish Pipeline was successful
All checks were successful
ci/woodpecker/push/publish Pipeline was successful
This commit is contained in:
parent
cc94b15e01
commit
9d0e2f6a7f
3 changed files with 50 additions and 0 deletions
|
@ -151,6 +151,9 @@ let tweet ctx msg =
|
||||||
| it :: [] -> it
|
| it :: [] -> it
|
||||||
| _ -> raise (Any "Too many tweet button found")
|
| _ -> raise (Any "Too many tweet button found")
|
||||||
in
|
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;
|
click ctx.session_id send_tweet_button;
|
||||||
Unix.sleep 8
|
Unix.sleep 8
|
||||||
;;
|
;;
|
||||||
|
|
40
lib/json.ml
40
lib/json.ml
|
@ -52,3 +52,43 @@ let send_keys_payload text =
|
||||||
(Yojson.Safe.to_string
|
(Yojson.Safe.to_string
|
||||||
(`List (List.map (fun str -> `String str) (keys_to_typing text))))
|
(`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
|
||||||
|
;;
|
||||||
|
|
|
@ -153,6 +153,13 @@ let click session_id element_id =
|
||||||
Json.empty)
|
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 get_attribute session_id element_id attribute =
|
||||||
let response =
|
let response =
|
||||||
execute_get_request
|
execute_get_request
|
||||||
|
|
Loading…
Reference in a new issue