Added a couple more error checks to Chrome Tab switching function

main
Yuriy 2 years ago
parent 6f2bc24753
commit 8b23cee3e9

@ -40,7 +40,7 @@ global UpdateVersionNumber
ScriptName = Freedomain Social Media Poster
ScriptVersion = 2.75
ScriptVersion = 2.76
FullScriptName := ScriptName . " " . ScriptVersion
;---ToDo---
@ -1561,6 +1561,8 @@ Return
;---------------/Facebook----------------------------------
/*
*/
; -------------------------------Parler-------------------------------
PostToParler:
@ -1887,178 +1889,179 @@ if(ImageAttachmentFilepath != ""){
Return
; -------------------------------/SubScribeStar-------------------------------
/*
*/
; -------------------------------LinkedIn-------------------------------
PostToLinkedIN:
CurrentSite := "LinkedIn"
; -------------------------------LinkedIn-------------------------------
PostToLinkedIN:
CurrentSite := "LinkedIn"
if(StrLen(PostTitleAndBody) > 1300){
Message = Post longer than LinkedIn's 1300 character limit. Posting Skipped.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
if(StrLen(PostTitleAndBody) > 1300){
Message = Post longer than LinkedIn's 1300 character limit. Posting Skipped.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
IniWrite, Skipped - Too Long, %StatusFileFilePath%, Status, LinkedIn
Return
}
IniWrite, Skipped - Too Long, %StatusFileFilePath%, Status, LinkedIn
Return
}
SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
URLAttempt := NavigateFromBaseURLTo("https://www.linkedin.com/login")
if(URLAttempt = "Failed")
Return
URLAttempt := NavigateFromBaseURLTo("https://www.linkedin.com/login")
if(URLAttempt = "Failed")
Status := CheckCurrentTabForCurrentSite()
if(Status){
Return
}
Status := CheckCurrentTabForCurrentSite()
if(Status){
Return
}
Message = Checking Login Status
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
Message = Checking Login Status
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
sleep, 1000
try CurrentTabURL := driver.Url
if(InStr(CurrentTabURL, "login")){
Message = Login Expired. Please log back in
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
sleep, 1000
try CurrentTabURL := driver.Url
if(InStr(CurrentTabURL, "login")){
Message = Login Expired. Please log back in
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
Message = Clicking "Start a Post" button
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
Message = Clicking "Start a Post" button
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
loop, 3 {
Xpath = (//span[normalize-space()='Start a post'])[1] ; start a post button
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
if(!Status)
Break
; Msgbox % "Status: " Status
if(Status AND A_index = 1){
try CurrentURL := driver.url
Message = Failed to click on "Start a post" button`nChecking Login Status`nCurrent URL: %CurrentURL%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
loop, 3 {
Xpath = (//span[normalize-space()='Start a post'])[1] ; start a post button
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
if(!Status)
Break
; Msgbox % "Status: " Status
if(Status AND A_index = 1){
try CurrentURL := driver.url
Message = Failed to click on "Start a post" button`nChecking Login Status`nCurrent URL: %CurrentURL%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
try html := driver.pagesource ; save page's entire HTML to a variable
if(InStr(HTML, "Sign In") AND InStr(HTML, "Forgot password")){
Xpath = //button[normalize-space()='Sign in']
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
sleep, 2000
driver.Get("https://www.linkedin.com/feed/") ;Open selected URL
; driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
continue
}
else, ; otherwise check and toggle the chat popup on the side
{
Message = Checking if Chat Sidebar is in the way
SaveOrPostProgress(Message:=Message,PostType:="Tooltip")
try html := driver.pagesource ; save page's entire HTML to a variable
if(InStr(HTML, "Sign In") AND InStr(HTML, "Forgot password")){
Xpath = //button[normalize-space()='Sign in']
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
sleep, 2000
driver.Get("https://www.linkedin.com/feed/") ;Open selected URL
; driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
continue
}
else, ; otherwise check and toggle the chat popup on the side
{
Message = Checking if Chat Sidebar is in the way
SaveOrPostProgress(Message:=Message,PostType:="Tooltip")
try html := driver.pagesource ; save page's entire HTML to a variable
if(InStr(HTML,"You are on the messaging overlay. Press enter to minimize it.")){ ; if sidebar is open
Xpath = //body//div//aside//button[2] ; click to minimize it
try driver.FindElementByXPath(Xpath).click()
Message = Chat sidebar was minimized
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Continue ; continue to next loop
}
if(InStr(HTML,"You are on the messaging overlay. Press enter to minimize it.")){ ; if sidebar is open
Xpath = //body//div//aside//button[2] ; click to minimize it
try driver.FindElementByXPath(Xpath).click()
Message = Chat sidebar was minimized
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Continue ; continue to next loop
}
}
; DevModeMsgBox("test")
; Check if linked in post popup appeared
Xpath = //div[@aria-label='Text editor for creating content']
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
if(Status){
Message = Failed to click into Create Post popup to input post
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
}
}
; DevModeMsgBox("test")
; Check if linked in post popup appeared
Xpath = //div[@aria-label='Text editor for creating content']
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
if(Status){
Message = Login Expired. Please log back in
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return
Message = Failed to click into Create Post popup to input post
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
}
}
if(ImageAttachmentFilepath != ""){
; Click the upload image button
SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile")
; click attach image button
Xpath = //li-icon[@type='image']//*[name()='svg']
Status := Selenium_LoopToClickXpathAndWaitForOpenWindow(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000)
if(Status){
Message = Failed to click "Attach Image" button with Selenium
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
if(Status){
Message = Login Expired. Please log back in
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return
}
Xpath = //input[@id='image-sharing-detour-container__file-input']
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath)
if(Status){
Message = Failed to Attach photo with both attempts.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
if(ImageAttachmentFilepath != ""){
; Click the upload image button
SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile")
if(WinExist("Open")) ; if open image popup still exists, close it
WinClose, Open
; Return
}
else, {
Status := InputFilePathIntoOpenWindow(ImageAttachmentFilepath)
if(Status)
{
Message = Failed to input filepath into "Open File" window.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
}
; sleep, 10000
; click attach image button
Xpath = //li-icon[@type='image']//*[name()='svg']
Status := Selenium_LoopToClickXpathAndWaitForOpenWindow(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000)
if(Status){
Message = Failed to click "Attach Image" button with Selenium
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Xpath = //span[normalize-space()='Done'] ; click done button
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=10,SleepLength:=1000)
Xpath = //input[@id='image-sharing-detour-container__file-input']
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath)
if(Status){
Message = Failed to click "Done" button on image upload
Message = Failed to Attach photo with both attempts.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
SaveOrPostProgress(Message:="Waiting 5 seconds for Image to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile")
sleep, 5000
if(WinExist("Open")) ; if open image popup still exists, close it
WinClose, Open
; Return
}
else, {
Status := InputFilePathIntoOpenWindow(ImageAttachmentFilepath)
if(Status)
{
Message = Failed to input filepath into "Open File" window.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
}
; sleep, 10000
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
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
Message = Inputting Post
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
SaveOrPostProgress(Message:="Waiting 5 seconds for Image to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile")
sleep, 5000
; Input Post text contents
loop, 3 {
Xpath = //div[@aria-label='Text editor for creating content'] ; Input text of post
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,StringTextContent:=PostTitleAndBody)
if(Status){
Message = Failed to input post content
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
}
}
; Double check that post got input
Jscheck = return document.querySelector("div[aria-label='Text editor for creating content']").innerText
try Status := driver.executeScript(Jscheck)
; DevModeMsgBox(Status)
if(StrLen(Status) > 5)
Break
Message = Inputting Post
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
if(A_index = 3){
Message = Post Failed: Failed to input Post for some reason
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
; Continue
; Input Post text contents
loop, 3 {
Xpath = //div[@aria-label='Text editor for creating content'] ; Input text of post
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,StringTextContent:=PostTitleAndBody)
if(Status){
Message = Failed to input post content
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
}
; Double check that post got input
Jscheck = return document.querySelector("div[aria-label='Text editor for creating content']").innerText
try Status := driver.executeScript(Jscheck)
; DevModeMsgBox(Status)
if(StrLen(Status) > 5)
Break
if(A_index = 3){
Message = Post Failed: Failed to input Post for some reason
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
; Continue
}
/* if(!Status){ ; if BLANK
Message = Post Failed: Failed to input Post for some reason
@ -2118,212 +2121,216 @@ if(ImageAttachmentFilepath != ""){
Return
; -------------------------------/LinkedIn-------------------------------
/*
*/
; -------------------------------Minds-------------------------------
PostToMinds:
CurrentSite := "Minds"
; -------------------------------Minds-------------------------------
PostToMinds:
CurrentSite := "Minds"
SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
URLAttempt := NavigateFromBaseURLTo("https://www.minds.com/newsfeed/subscriptions")
if(URLAttempt = "Failed")
URLAttempt := NavigateFromBaseURLTo("https://www.minds.com/newsfeed/subscriptions")
if(URLAttempt = "Failed")
Return
Status := CheckCurrentTabForCurrentSite()
if(Status){
Return
}
Status := CheckCurrentTabForCurrentSite()
if(Status){
Return
}
sleep, 1000
sleep, 1000
try CurrentTabURL := driver.Url
; Msgbox % "CurrentTabURL: " CurrentTabURL
if(InStr(CurrentTabURL, "login")){
Message = Login Cookies Expired. Trying to Re-Login
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
sleep, 2000
Xpath = //div[contains(text(),'Login')]
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
}
try CurrentTabURL := driver.Url
; Msgbox % "CurrentTabURL: " CurrentTabURL
if(InStr(CurrentTabURL, "login")){
Message = Login Cookies Expired. Trying to Re-Login
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
sleep, 2000
Xpath = //div[contains(text(),'Login')]
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
Message = Clicking into Speak your mind.. Box
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
loop, 3 {
if(A_index = 3){
SaveOrPostProgress(Message:="Failed to click into -speak your mind..- input box.",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
Message = Clicking into Speak your mind.. Box
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
; Click the Big Compose Box at the top of the page
Xpath = //div[@class='m-composer__triggerOverlay']
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=10,SleepLength:=1000)
; Status := Selenium_LoopToClickXpath(Xpath,5,1000)
if(Status){
SaveOrPostProgress(Message:="Login Expired. Please log back in",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
loop, 3 {
if(A_index = 3){
SaveOrPostProgress(Message:="Failed to click into -speak your mind..- input box.",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
; check that popup appears by checking for "Create Blog" button in popup
js = return document.querySelector("div[class='m-composer__base'] div[class='m-composerTitleBar__createBlogTrigger ng-star-inserted']").innerText
try status := driver.executeScript(js)
if(InStr(Status, "Create Blog")){
break
}
else, {
continue
}
; Msgbox % "status: " status
; Click the Big Compose Box at the top of the page
Xpath = //div[@class='m-composer__triggerOverlay']
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=10,SleepLength:=1000)
; Status := Selenium_LoopToClickXpath(Xpath,5,1000)
if(Status){
SaveOrPostProgress(Message:="Login Expired. Please log back in",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
; check that popup appears by checking for "Create Blog" button in popup
js = return document.querySelector("div[class='m-composer__base'] div[class='m-composerTitleBar__createBlogTrigger ng-star-inserted']").innerText
try status := driver.executeScript(js)
if(InStr(Status, "Create Blog")){
break
}
else, {
continue
}
; Msgbox % "status: " status
}
; Attach Image
if(ImageAttachmentFilepath != ""){
; Click the upload image button
SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile")
Xpath = //input[@type='file']
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath)
if(Status){
Message = Failed to attach image (E#1203)
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
; Attach Image
if(ImageAttachmentFilepath != ""){
; Click the upload image button
SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile")
SaveOrPostProgress(Message:="Waiting 2 seconds for Image to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile")
sleep, 2000
Xpath = //input[@type='file']
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath)
if(Status){
Message = Failed to attach image (E#1203)
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
SaveOrPostProgress(Message:="Waiting 2 seconds for Image to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile")
SaveOrPostProgress(Message:="Inputting Post Content`nMight take 5-15 seconds to get input",PostType:="Tooltip,ErrorLoggingTextFile")
sleep, 2000
; Click the plus button to make the title box show up
Xpath = //div[@class='m-composer__base m-composer__base--withPreview']//i[@class='material-icons ng-star-inserted'][normalize-space()='add_circle_outline']
try driver.FindElementByXPath(Xpath).click()
catch e { ; if failed to plus button, then input the post body and text into the same box
; msgbox, failed to click Plus
; goto, InputMindsPostCombined
}
; if plus button was clicked successfully, input title and body individually
; Input title
; Msgbox % "PostTitle: " PostTitle
Xpath = //textarea[@placeholder='Title']
; driver.FindElementByXPath(Xpath).SendKeys("heleeoeoe")
SaveOrPostProgress(Message:="Inputting Post Content`nMight take 5-15 seconds to get input",PostType:="Tooltip,ErrorLoggingTextFile")
; CLick into title box
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
; Click the plus button to make the title box show up
Xpath = //div[@class='m-composer__base m-composer__base--withPreview']//i[@class='material-icons ng-star-inserted'][normalize-space()='add_circle_outline']
try driver.FindElementByXPath(Xpath).click()
catch e { ; if failed to plus button, then input the post body and text into the same box
; msgbox, failed to click Plus
; goto, InputMindsPostCombined
}
; if plus button was clicked successfully, input title and body individually
; Input title
; Msgbox % "PostTitle: " PostTitle
Xpath = //textarea[@placeholder='Title']
; driver.FindElementByXPath(Xpath).SendKeys("heleeoeoe")
; Input text itno title box
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitle)
if(Status){ ; if failed to input title then skip to inputting both combined
; msgbox, failed to input title
Message = Failed to input Title
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; CLick into title box
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
MindsTitleStatus := "Failed"
; Return
; Input text itno title box
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitle)
if(Status){ ; if failed to input title then skip to inputting both combined
; msgbox, failed to input title
Message = Failed to input Title
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
MindsTitleStatus := "Failed"
; Return
; goto, InputMindsPostCombined
}
; msgbox, title input?
; Input body
if(MindsTitleStatus)
MindsPost := PostTitleAndBody
else, MindsPost := PostBody
; goto, InputMindsPostCombined
; Msgbox % "PostBody: " PostBody
Xpath = //textarea[@id='minds-m-composer__textarea--1003']
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=MindsPost)
if(Status){
; msgbox, failed to input body
Message = Failed to post with Xpath, trying with ID
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Status := Selenium_LoopToSendValueToID("minds-m-composer__textarea--1003",5,1000,MindsPost)
if(Status){
Message = Failed to input Post Content into Page
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
}
}
else, { ; otherwise, input just text
SaveOrPostProgress(Message:="Inputting Text Post",PostType:="Tooltip,ErrorLoggingTextFile")
; DevModeMsgBox("Inputting Text Post")
Xpath = //textarea[@id='minds-m-composer__textarea--1003']
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitleAndBody)
; msgbox, title input?
; Input body
if(MindsTitleStatus)
MindsPost := PostTitleAndBody
else, MindsPost := PostBody
; Msgbox % "PostBody: " PostBody
Xpath = //textarea[@id='minds-m-composer__textarea--1003']
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=MindsPost)
if(Status){
Message = Failed to post with Xpath, trying with ID
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Status := Selenium_LoopToSendValueToID("minds-m-composer__textarea--1003",5,1000,PostTitleAndBody)
if(Status){
; msgbox, failed to input body
Message = Failed to post with Xpath, trying with ID
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Status := Selenium_LoopToSendValueToID("minds-m-composer__textarea--1003",5,1000,MindsPost)
if(Status){
Message = Failed to input Post Content into Page
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
Message = Failed to input Post Content into Page
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
} else, { ; otherwise, input just text
SaveOrPostProgress(Message:="Inputting Text Post",PostType:="Tooltip,ErrorLoggingTextFile")
; DevModeMsgBox("Inputting Text Post")
Xpath = //textarea[@id='minds-m-composer__textarea--1003']
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitleAndBody)
DevModeMsgBox("done")
if(Status){
Message = Failed to post with Xpath, trying with ID
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Status := Selenium_LoopToSendValueToID("minds-m-composer__textarea--1003",5,1000,PostTitleAndBody)
if(Status){
Message = Failed to input Post Content into Page
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
}
}
if(InStr(PostBody,"http"))
{
Message = Sleeping 5 seconds for preview to load
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile")
sleep, 5000
}
if(InStr(PostBody,"http"))
{
Message = Sleeping 5 seconds for preview to load
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile")
sleep, 5000
}
}
}
; sleep, 2000
SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile")
; sleep, 2000
SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile")
loop, 3 {
if(A_index = 3){
SaveOrPostProgress(Message:="Failed to submit post",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
loop, 3 {
if(A_index = 3){
SaveOrPostProgress(Message:="Failed to submit post",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
; click submit button
js = document.querySelector("button[class='m-button m-button--blue m-button--small m-button--dropdown'] span[class='ng-star-inserted']").click();
try status := driver.executeScript(js)
catch e {
Msgbox % "status: " status
; click submit button
js = document.querySelector("button[class='m-button m-button--blue m-button--small m-button--dropdown'] span[class='ng-star-inserted']").click();
try status := driver.executeScript(js)
catch e {
Message = Clicking submit button with JS resulted in status: %status%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
}
}
SaveOrPostProgress(Message:="Waiting 5 seconds to confirm post got submitted",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
sleep, 5000
SaveOrPostProgress(Message:="Waiting 5 seconds to confirm post got submitted",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
sleep, 5000
; check that popup appears by checking for "Create Blog" button in popup
js = return document.querySelector("div[class='m-composer__base'] div[class='m-composerTitleBar__createBlogTrigger ng-star-inserted']").innerText
try status := driver.executeScript(js)
if(InStr(Status, "Create Blog")){
continue
}
else, {
break
}
; check that popup appears by checking for "Create Blog" button in popup
js = return document.querySelector("div[class='m-composer__base'] div[class='m-composerTitleBar__createBlogTrigger ng-star-inserted']").innerText
try status := driver.executeScript(js)
if(InStr(Status, "Create Blog")){
continue
}
else, {
break
}
}
}
/* if(!TestingMode){
@ -2361,71 +2368,80 @@ if(ImageAttachmentFilepath != ""){
Return
; -------------------------------/Minds-------------------------------
; -------------------------------Locals-------------------------------
PostToLocals:
CurrentSite := "Locals"
; DevModeMsgBox("clik ok to continue")
; @todo: Add auto-login to locals
SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
/*
*/
IniRead, LocalsURL, %SettingsIniFilepath%, %ScriptSettingsSection%, LocalsURL
Message = LocalsURL from Ini File: %LocalsURL%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; -------------------------------Locals-------------------------------
PostToLocals:
CurrentSite := "Locals"
; DevModeMsgBox("clik ok to continue")
; @todo: Add auto-login to locals
SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; LocalsURL := StrReplace(Localsurl, "/share/post", "")
; LocalsURL := Localsurl . "/login"
; Message = Localsurl: %LocalsURL%
; SaveOrPostProgress(Message:=Message,PostType:=",DiscordErrorLogging")
IniRead, LocalsURL, %SettingsIniFilepath%, %ScriptSettingsSection%, LocalsURL, %A_Space%
if(LocalsURL = ""){
Message = Please add your Locals Profile URL to the settings.ini file under`n`n[General]`nLocalsURL=
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return
}
Status := NavigateFromBaseURLTo(LocalsURL)
if(Status = "Failed")
Return
; Message = LocalsURL from Ini File: %LocalsURL%
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Status := CheckCurrentTabForCurrentSite()
if(Status){
Return
}
sleep, 1000
; LocalsURL := StrReplace(Localsurl, "/share/post", "")
; LocalsURL := Localsurl . "/login"
; Message = Localsurl: %LocalsURL%
; SaveOrPostProgress(Message:=Message,PostType:=",DiscordErrorLogging")
Message = Checking Login Status
Status := NavigateFromBaseURLTo(LocalsURL)
if(Status = "Failed")
Return
try CurrentTabURL := driver.Url
if(InStr(CurrentTabURL, "/login") OR InStr(CurrentTabURL, "/register")){
Message = Login Expired. Please log back in
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
Status := CheckCurrentTabForCurrentSite()
if(Status){
Return
}
sleep, 1000
Message = Checking Login Status
try CurrentTabURL := driver.Url
if(InStr(CurrentTabURL, "/login") OR InStr(CurrentTabURL, "/register")){
Message = Login Expired. Please log back in
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
; Xpath = //textarea[@id='body']
; Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=2000)
; if(Status){
; Message = Trying to Log Back In
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; LocalsLoginURL := LocalsURL . "/login"
; try driver.Get(LocalsLoginURL) ;Open selected URL
; try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
; sleep, 3000
; js = document.getElementsByName('submit')[0].click();
; try driver.executeScript(js)
; ; DevModeMsgBox(js)
; ; clipboard := js
; try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
; sleep, 5000
; ; try driver.Get(LocalsURL) ;Open selected URL
; ; try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
; Xpath = //textarea[@id='body']
; Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=2000)
; {
; Message = Post Failed: Check Login Status
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
; Return
; }
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
; Xpath = //textarea[@id='body']
; Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=2000)
; if(Status){
; Message = Trying to Log Back In
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; LocalsLoginURL := LocalsURL . "/login"
; try driver.Get(LocalsLoginURL) ;Open selected URL
; try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
; sleep, 3000
; js = document.getElementsByName('submit')[0].click();
; try driver.executeScript(js)
; ; DevModeMsgBox(js)
; ; clipboard := js
; try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
; sleep, 5000
; ; try driver.Get(LocalsURL) ;Open selected URL
; ; try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
; Xpath = //textarea[@id='body']
; Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=2000)
; {
; Message = Post Failed: Check Login Status
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
; Return
; }
/* Message = Post Failed: Check Login Status
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")

@ -1 +1 @@
Subproject commit f056489f509d570de33c67e023e3edc5296fe3ac
Subproject commit 8a4c74ffafc09cdc5c7eebca06e4e9da2a71e79c
Loading…
Cancel
Save