From 5ed47d281c7f2aaa9e22c9aac3fbccb89afe80c0 Mon Sep 17 00:00:00 2001 From: yuriy Date: Sun, 5 Nov 2023 16:44:36 -0500 Subject: [PATCH] added title input for Locals Posts --- Modules/Post-To-Locals.ahk | 57 +++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 32 deletions(-) diff --git a/Modules/Post-To-Locals.ahk b/Modules/Post-To-Locals.ahk index 82175fd..3dc3d28 100644 --- a/Modules/Post-To-Locals.ahk +++ b/Modules/Post-To-Locals.ahk @@ -41,12 +41,22 @@ if(InStr(CurrentTabURL, "/login") OR InStr(CurrentTabURL, "/register")){ Message = Inputting Post Content SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") +Xpath = //input[@id='title'] +try driver.FindElementByXPath(Xpath).click() +Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitle) +if(Status){ + Message = Failed to input Title + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} + Xpath = //*[@id="body"] try driver.FindElementByXPath(Xpath).click() -Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitleAndBody) +Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostBody) if(Status){ - Message = Failed to input Title + Message = Failed to input Body SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") SaveDriverURLOFErrorPage() Return @@ -79,39 +89,22 @@ if(ImageAttachmentFilepath != ""){ Message = Submitting Post SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") +; Click Publish post +js = document.getElementsByName('submitPost')[0].click(); ; Send content through javascript (Great for getting around emoji chrome limitaitons) +try driver.executeScript(js) +Message = Double checking that post got submitted +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") +; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") +sleep, 5000 -/* ; Click the final "post" button - SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") - Status := Selenium_LoopToClickName(ElementName:="submitPost",NumOfLoops:=5,SleepLength:=1000) - if(Status){ - Message = Failed to Submit Post - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return - } - - */ - - ; msgbox - - ; @todo: add error check into here to check the current page url and after page url - ; Click Publish post - js = document.getElementsByName('submitPost')[0].click(); ; Send content through javascript (Great for getting around emoji chrome limitaitons) - try driver.executeScript(js) - - Message = Double checking that post got submitted - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - sleep, 5000 - - - try CurrentTabURL := driver.Url - if(InStr(CurrentTabURL, "share/post")) { ; post failed to submit if it's still on the create new post page - Message = Error: Post Was Input but Failed to Submit. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return +try CurrentTabURL := driver.Url +if(InStr(CurrentTabURL, "share/post")) { ; post failed to submit if it's still on the create new post page +Message = Error: Post Was Input but Failed to Submit. +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") +SaveDriverURLOFErrorPage() +Return }