click to profile
This commit is contained in:
parent
d5a7c3d0ed
commit
f04b3fa763
4 changed files with 26 additions and 3 deletions
|
@ -25,7 +25,8 @@ let main ctx =
|
|||
| None, Some _ -> raise (Any "Username not set")
|
||||
| Some _, None -> raise (Any "Password not set")
|
||||
in
|
||||
login_twitter ctx username password (Sys.getenv_opt "TWITTER_TOTP")
|
||||
login_twitter ctx username password (Sys.getenv_opt "TWITTER_TOTP");
|
||||
go_to_profile ctx
|
||||
;;
|
||||
|
||||
let handler data (signal : int) =
|
||||
|
|
|
@ -80,3 +80,16 @@ let login_twitter ctx username password secret =
|
|||
then raise (Any "Too many elements found as 2FA input")
|
||||
else inject_2fa ctx.session_id secret (List.nth l 0)
|
||||
;;
|
||||
|
||||
let go_to_profile ctx =
|
||||
let profile_button =
|
||||
match find ctx.session_id (XPath "//a[@data-testid='AppTabBar_Profile_Link']") with
|
||||
| [] -> raise (Any (fmt "Profile button not found"))
|
||||
| _ as l ->
|
||||
if List.length l > 1
|
||||
then raise (Any "Too many profile button found")
|
||||
else List.nth l 0
|
||||
in
|
||||
click ctx.session_id profile_button;
|
||||
Unix.sleep 4
|
||||
;;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
open Utils
|
||||
|
||||
let empty = "{}"
|
||||
|
||||
let connection_payload headless =
|
||||
fmt
|
||||
{|
|
||||
|
|
11
lib/net.ml
11
lib/net.ml
|
@ -115,9 +115,16 @@ let find session_id strategy =
|
|||
| _ -> raise (Any "wait_for_load | Invalid JSON")
|
||||
;;
|
||||
|
||||
let send_keys session_id element_id username =
|
||||
let send_keys session_id element_id data =
|
||||
ignore
|
||||
(execute_post_request
|
||||
(fmt "%s/element/%s/value" (driver session_id) element_id)
|
||||
(Json.send_keys_payload username))
|
||||
(Json.send_keys_payload data))
|
||||
;;
|
||||
|
||||
let click session_id element_id =
|
||||
ignore
|
||||
(execute_post_request
|
||||
(fmt "%s/element/%s/click" (driver session_id) element_id)
|
||||
Json.empty)
|
||||
;;
|
||||
|
|
Loading…
Reference in a new issue