diff --git a/Modules/Post-To-LinkedIn.ahk b/Modules/Post-To-LinkedIn.ahk index be4944c..ca2f206 100644 --- a/Modules/Post-To-LinkedIn.ahk +++ b/Modules/Post-To-LinkedIn.ahk @@ -97,7 +97,7 @@ if(ImageAttachmentFilepath != ""){ SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile") ; click attach image button - Xpath = //li-icon[@type='image']//*[name()='svg'] + Xpath = //button[@aria-label='Add media'] Status := Selenium_LoopToClickXpathAndWaitForOpenWindow(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) if(Status){ Message = Failed to click "Attach Image" button with Selenium @@ -117,7 +117,35 @@ if(ImageAttachmentFilepath != ""){ ; Return } else, { - Status := InputFilePathIntoOpenWindow(ImageAttachmentFilepath) + if(WinExist("Open")){ + Message = Closing "Open" Popup Window so Image can be send directly to input element + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + WinClose, Open + } + + Xpath = //input[@id='media-editor-file-selector__file-input'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath) + if(Status){ + Message = Post Failed: Failed to Upload Image by sending directly to element. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + Xpath = //span[normalize-space()='Next'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ + Message = Post Failed. Image was attached successfully but failed to navigate back to New Post Page + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + + ; driver.FindElementByXPath(Xpath).SendKeys(ImageAttachmentFilepath) + +/* Status := InputFilePathIntoOpenWindow(ImageAttachmentFilepath) if(Status) { Message = Failed to input filepath into "Open File" window. @@ -125,10 +153,11 @@ if(ImageAttachmentFilepath != ""){ SaveDriverURLOFErrorPage() Return } + */ } ; sleep, 10000 - Xpath = //span[normalize-space()='Done'] ; click done button +/* Xpath = //span[normalize-space()='Done'] ; click done button Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=10,SleepLength:=1000) if(Status){ Message = Failed to click "Done" button on image upload @@ -139,6 +168,7 @@ if(ImageAttachmentFilepath != ""){ SaveOrPostProgress(Message:="Waiting 5 seconds for Image to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile") sleep, 5000 +*/ }