expanded error checking functions

main
Yuriy 2 years ago
parent a15743a156
commit c3dabf54b4

@ -2007,9 +2007,9 @@ if(InStr(CurrentTabURL, "/login")){
Return
Status := CheckCurrentTabForCurrentSite()
if(Status){
if(Status){
Return
}
}
Message = Checking Login Status
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
@ -2227,9 +2227,9 @@ if(Status){
Return
Status := CheckCurrentTabForCurrentSite()
if(Status){
if(Status){
Return
}
}
sleep, 1000
@ -2455,7 +2455,7 @@ if(Status){
; -------------------------------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")
@ -2472,10 +2472,10 @@ if(Status){
if(Status = "Failed")
Return
Status := CheckCurrentTabForCurrentSite()
if(Status){
Status := CheckCurrentTabForCurrentSite()
if(Status){
Return
}
}
sleep, 1000
Message = Checking Login Status
@ -2668,10 +2668,10 @@ if(Status){
if(URLAttempt = "Failed")
Return
Status := CheckCurrentTabForCurrentSite()
if(Status){
Status := CheckCurrentTabForCurrentSite()
if(Status){
Return
}
}
sleep, 1000
Message = Checking Login Status
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
@ -2779,10 +2779,10 @@ if(Status){
if(URLAttempt = "Failed")
Return
Status := CheckCurrentTabForCurrentSite()
if(Status){
Status := CheckCurrentTabForCurrentSite()
if(Status){
Return
}
}
; Loop a bunch of times for page to load
SaveOrPostProgress(Message:="Waiting for Page to Load Fully",PostType:="Tooltip,ErrorLoggingTextFile")
loop, 12 {
@ -3040,10 +3040,10 @@ if(Status){
if(URLAttempt = "Failed")
Return
Status := CheckCurrentTabForCurrentSite()
if(Status){
Status := CheckCurrentTabForCurrentSite()
if(Status){
Return
}
}
Message = Checking for Content from Previous Post
@ -3232,9 +3232,9 @@ if(Status){
Return
Status := CheckCurrentTabForCurrentSite()
if(Status){
if(Status){
Return
}
}
sleep, 1000
SaveOrPostProgress(Message:="Checking Login Status",PostType:="Tooltip,ErrorLoggingTextFile")
@ -3387,10 +3387,10 @@ if(Status){
if(URLAttempt = "Failed")
Return
Status := CheckCurrentTabForCurrentSite()
if(Status){
Status := CheckCurrentTabForCurrentSite()
if(Status){
Return
}
}
Message = Inputting Post Content
@ -3775,10 +3775,10 @@ CurrentSite := "Twetch"
if(URLAttempt = "Failed")
Return
Status := CheckCurrentTabForCurrentSite()
if(Status){
Status := CheckCurrentTabForCurrentSite()
if(Status){
Return
}
}
sleep, 1000

@ -948,21 +948,21 @@ if(TotalTabsFound = 1){
ToolTip,
}
CheckCurrentTabForCurrentSite(){
try CurrentTabURL := driver.url
CheckCurrentTabForCurrentSite(){
try CurrentTabURL := driver.url
if(!InStr(CurrentTabURL, "CurrentSite")){
if(!InStr(CurrentTabURL, CurrentSite)){
Message = Chromedriver failed to switch to %CurrentSite%. Please see errorlog for website it got stuck on.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
return "Failed"
}
}
; msgbox % InStr(CurrentTabURL,CurrentSite)
; msgbox % InStr(CurrentTabURL,CurrentSite)
}
}
; -------------------------------NavigateFromBaseURLTo-------------------------------
@ -1153,16 +1153,20 @@ SChrome_Get(URL := "", Profile := "Profile 1", IP_Port := "127.0.0.1:9222"){
run, %ChromeFilepath% --remote-debugging-port=%IP_Port_Nr% %URL%
}
; Driver.Timeout := 1000
Driver := ComObjCreate("Selenium.ChromeDriver")
Driver.SetCapability("debuggerAddress", IP_Port)
SaveOrPostProgress(Message:="Trying to connect to Chrome.`nIf stuck here check for dialog popups or your ChromeDriver`nClose chrome to break out of program being stuck.",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar")
; set selenium timeout to 1 second, instead of default 5 seconds
try Driver.Start()
catch e {
ShowSeleniumErrorMsgbox()
}
} ; end of catch
; Save current chrome version to ini file
return Driver
}
; -------------------------------/SChrome_Get-------------------------------
@ -1172,6 +1176,24 @@ SChrome_Get(URL := "", Profile := "Profile 1", IP_Port := "127.0.0.1:9222"){
Chromeversion := RunCMD(GetChromeVersionCommand)
ChromeVersion := StrReplace(ChromeVersion, "`n", "")
Message = Failed to connect to Chrome
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
/*
; check for alert popup
try alertText := driver.SwitchToAlert().Text
; DevModeMsgBox(alertText)
if(alertText){
Message = Alert Popup Text: %alertText%
SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,ErrorSummaryVar")
SaveOrPostProgress(Message:="Chrome stuck on alert popup",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
DevModeMsgBox("alert popup found")
}
*/
; Msgbox % "alertText: " alertText
; Clipboard := ChromeVersion
; Msgbox % "Chromeversion: " Chromeversion
IniRead, PreviousWorkingChromeVersion, Settings.ini, Misc, ChromeVersion, %A_Space%
@ -1181,7 +1203,7 @@ SChrome_Get(URL := "", Profile := "Profile 1", IP_Port := "127.0.0.1:9222"){
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
OnMessage(0x44, "OnMsgBoxChromeDriverFailed")
MsgBox 0x40043, Error, Failed to Connect to Chrome. `nMost likely issue is either Chrome has some sort of dialogue box open or ChromeDriver needs to be updated.`n`nClick "Reload" to reload the script to try again`nClick "ChromeDriver" to open up the ChromeDriver download page. `n`nClick "Instructions" to open up .pdf file with instructions for updating chromedriver.exe`n`nPossibly Helpful Info:`nCurrent Chrome Version: %Chromeversion%Chrome Version of Last Successfull Upload: %PreviousWorkingChromeVersion%
MsgBox 0x40043, Error, Failed to Connect to Chrome. `nMost likely issue is either Chrome has some sort of dialogue box open or ChromeDriver needs to be updated.`n`nClick "Reload" to reload with your Last Post`nClick "ChromeDriver" to open up the ChromeDriver download page. `n`nClick "Instructions" to open up installation instructions in your default browser.`n`n Information:`nCurrent Chrome Version: %Chromeversion%Chrome Version of Last Successfull Upload: %PreviousWorkingChromeVersion%
OnMessage(0x44, "")
IfMsgBox Yes, {
@ -1189,18 +1211,13 @@ SChrome_Get(URL := "", Profile := "Profile 1", IP_Port := "127.0.0.1:9222"){
Reload
} Else IfMsgBox No, {
run, https://chromedriver.chromium.org/downloads
run, "%A_ScriptFullPath%" "LastPost"
ExitApp
; open chromedriver site
} Else IfMsgBox Cancel, {
URL = https://freedomainplaylists.com/wp-content/FreedomainScripts/Update`%20Selenium`%20ChromeDriver.pdf
Filepath = %A_ScriptDir%\Lib\Update Selenium ChromeDriver.pdf
if(!FileExist(Filepath)){
UrlDownloadToFile, %URL%, %Filepath%
run, %Filepath%
}
run, "https://git.zinchuk.xyz/yuriy/Freedomain-Social-Media-Poster#installation"
run, "%A_ScriptFullPath%" "LastPost"
ExitApp
}
}

Loading…
Cancel
Save