From e8fde14350458ab17e5442ee00ed32c8f1427259 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Mon, 15 May 2023 15:09:24 +0200 Subject: [PATCH] click on tweet button --- bin/twitter.ml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bin/twitter.ml b/bin/twitter.ml index 73c433d..93f88d4 100644 --- a/bin/twitter.ml +++ b/bin/twitter.ml @@ -134,4 +134,15 @@ let find_latest_tweet ctx = Some (List.fold_left max min_int datetimes) ;; -let tweet _ctx _msg = () +let tweet ctx _msg = + let tweet_button = + match find ctx.session_id (XPath "//a[@data-testid='SideNav_NewTweet_Button']") with + | [] -> raise (Any (fmt "Tweet button not found")) + | _ as l -> + if List.length l > 1 + then raise (Any "Too many tweet button found") + else List.nth l 0 + in + click ctx.session_id tweet_button; + Unix.sleep 4 +;;