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,52 +1889,53 @@ if(ImageAttachmentFilepath != ""){
Return
; -------------------------------/SubScribeStar-------------------------------
/*
*/
; -------------------------------LinkedIn-------------------------------
PostToLinkedIN:
CurrentSite := "LinkedIn"
; -------------------------------LinkedIn-------------------------------
PostToLinkedIN:
CurrentSite := "LinkedIn"
if(StrLen(PostTitleAndBody) > 1300){
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
}
}
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")
Return
Status := CheckCurrentTabForCurrentSite()
if(Status){
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")){
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 {
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)
@ -1974,15 +1977,15 @@ if(ImageAttachmentFilepath != ""){
Message = Failed to click into Create Post popup to input post
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
}
}
}
if(Status){
if(Status){
Message = Login Expired. Please log back in
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return
}
}
if(ImageAttachmentFilepath != ""){
if(ImageAttachmentFilepath != ""){
; Click the upload image button
SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile")
@ -2030,13 +2033,13 @@ if(ImageAttachmentFilepath != ""){
SaveOrPostProgress(Message:="Waiting 5 seconds for Image to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile")
sleep, 5000
}
}
Message = Inputting Post
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
Message = Inputting Post
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
; Input Post text contents
loop, 3 {
; 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){
@ -2058,7 +2061,7 @@ if(ImageAttachmentFilepath != ""){
Return
}
; Continue
}
}
/* if(!Status){ ; if BLANK
Message = Post Failed: Failed to input Post for some reason
@ -2118,43 +2121,45 @@ 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")
Return
URLAttempt := NavigateFromBaseURLTo("https://www.minds.com/newsfeed/subscriptions")
if(URLAttempt = "Failed")
Return
Status := CheckCurrentTabForCurrentSite()
if(Status){
Status := CheckCurrentTabForCurrentSite()
if(Status){
Return
}
}
sleep, 1000
sleep, 1000
try CurrentTabURL := driver.Url
; Msgbox % "CurrentTabURL: " CurrentTabURL
if(InStr(CurrentTabURL, "login")){
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")
Message = Clicking into Speak your mind.. Box
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
loop, 3 {
loop, 3 {
if(A_index = 3){
SaveOrPostProgress(Message:="Failed to click into -speak your mind..- input box.",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
@ -2186,10 +2191,10 @@ if(ImageAttachmentFilepath != ""){
}
}
; Attach Image
if(ImageAttachmentFilepath != ""){
; Attach Image
if(ImageAttachmentFilepath != ""){
; Click the upload image button
SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile")
@ -2261,13 +2266,14 @@ if(ImageAttachmentFilepath != ""){
Return
}
}
} else, { ; otherwise, input just text
}
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")
@ -2288,13 +2294,13 @@ if(ImageAttachmentFilepath != ""){
sleep, 5000
}
}
}
; sleep, 2000
SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile")
; sleep, 2000
SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile")
loop, 3 {
loop, 3 {
if(A_index = 3){
SaveOrPostProgress(Message:="Failed to submit post",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
@ -2305,7 +2311,8 @@ if(ImageAttachmentFilepath != ""){
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
Message = Clicking submit button with JS resulted in status: %status%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
}
@ -2323,7 +2330,7 @@ if(ImageAttachmentFilepath != ""){
}
}
}
/* if(!TestingMode){
@ -2361,46 +2368,55 @@ 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")
/*
*/
; LocalsURL := StrReplace(Localsurl, "/share/post", "")
; LocalsURL := Localsurl . "/login"
; Message = Localsurl: %LocalsURL%
; SaveOrPostProgress(Message:=Message,PostType:=",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")
Status := NavigateFromBaseURLTo(LocalsURL)
if(Status = "Failed")
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 := CheckCurrentTabForCurrentSite()
if(Status){
; Message = LocalsURL from Ini File: %LocalsURL%
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; LocalsURL := StrReplace(Localsurl, "/share/post", "")
; LocalsURL := Localsurl . "/login"
; Message = Localsurl: %LocalsURL%
; SaveOrPostProgress(Message:=Message,PostType:=",DiscordErrorLogging")
Status := NavigateFromBaseURLTo(LocalsURL)
if(Status = "Failed")
Return
Status := CheckCurrentTabForCurrentSite()
if(Status){
Return
}
sleep, 1000
}
sleep, 1000
Message = Checking Login Status
Message = Checking Login Status
try CurrentTabURL := driver.Url
if(InStr(CurrentTabURL, "/login") OR InStr(CurrentTabURL, "/register")){
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){
; 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")

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