Added extra check to Chrome Tab Activation Function and extra debug error logging

main
Yuriy 2 years ago
parent 89c1042e01
commit 694c440a6a

@ -730,26 +730,6 @@ CheckIfUpdateAvailable(Filepath, CurrentVersion){
FindUpdateChangeLog(Filepath){
FileRead, ScriptUpdateContents, %Filepath%
; Set Variables
ChangelogStart =;---Changelog------------------------------------------------------
ChangelogEnd =;---/Changelog------------------------------------------------------
; Msgbox % "ScriptUpdateContents: " ScriptUpdateContents
ChangeLog := StrSplit(ScriptUpdateContents, ChangelogStart)
ChangeLog := ChangeLog[2]
ChangeLog := StrSplit(ChangeLog, ChangelogEnd)
ChangeLog := ChangeLog[1]
Return Changelog
}
CheckSeleniumDriver(){ CheckSeleniumDriver(){
try Driver := SChrome_Get("", ChromeProfile := "") ; open new tab page with with specified profile try Driver := SChrome_Get("", ChromeProfile := "") ; open new tab page with with specified profile
catch e { catch e {
@ -790,6 +770,9 @@ SeleniumConnectToActiveTab(IP_Port := "127.0.0.1:9222"){
return Driver return Driver
} }
/*
*/
CreateArrayOfChromeTabs() { CreateArrayOfChromeTabs() {
Message = Creating an Array of All Chrome Tabs Message = Creating an Array of All Chrome Tabs
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
@ -895,9 +878,11 @@ CreateArrayOfChromeTabs() {
return return
} }
/*
*/
InputFilePathIntoOpenWindow(Filepath){ InputFilePathIntoOpenWindow(Filepath){
; Msgbox % "Filepath: " Filepath ; Msgbox % "Filepath: " Filepath
Message = Waiting for "Open" window to appear to input filepath into Message = Waiting for "Open" window to appear to input filepath into
@ -969,6 +954,10 @@ ActivateChromeTab(URL){
; NumberOfTabLoops := Driver.Windows.Count + 2 ; NumberOfTabLoops := Driver.Windows.Count + 2
loop % NumberOfTabActivationLoops { ; loop through tabs to find matching tab loop % NumberOfTabActivationLoops { ; loop through tabs to find matching tab
Message = Looping through tabs to activate with: %URLBase%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
try driver.SwitchToNextWindow() try driver.SwitchToNextWindow()
; sleep, 1000 ; sleep, 1000
@ -1014,8 +1003,12 @@ return "Failed"
NavigateFromBaseURLTo(URL,PageTitle := "TodoDeleteme"){ NavigateFromBaseURLTo(URL,PageTitle := "TodoDeleteme"){
if(!DriverStatus){ ; if not connected to selenium chrome, then re-connect if(!DriverStatus){ ; if not connected to selenium chrome, then re-connect
Status := CheckSeleniumDriver() Status := CheckSeleniumDriver()
if(Status) if(Status){
Message = Failed to Connect to Chrome. Please Check for any open dialog boxes or ChromeDriver being out of date.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return "Failed" Return "Failed"
}
; CreateArrayOfChromeTabs() ; moved to the end of checkseleniumdriver() ; CreateArrayOfChromeTabs() ; moved to the end of checkseleniumdriver()
} }
@ -1044,11 +1037,16 @@ NavigateFromBaseURLTo(URL,PageTitle := "TodoDeleteme"){
if(!HasSubstringVal(ChromeTabsURLArray, URLBase)) if(!HasSubstringVal(ChromeTabsURLArray, URLBase))
{ {
; DevModeMsgBox("Creating new tab") ; DevModeMsgBox("Creating new tab")
Message = Tab for %urlBase% does not exist. Creating new tab with URL: %URL%
try, run "%ChromeFilepath%" "%URL%" try, run "%ChromeFilepath%" "%URL%"
ChromeTabsURLArray.Push(URL) ; Append the new url to the array ChromeTabsURLArray.Push(URL) ; Append the new url to the array
NewTabCreated := 1 NewTabCreated := 1
sleep, 1000 sleep, 1000
} }
else, {
Message = %URLBase% is within ChromeTabsURLArray. Trying to Activate.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
}
; message = NewTabCreated: %NewTabCreated% ; message = NewTabCreated: %NewTabCreated%
; DevModeMsgBox(message) ; DevModeMsgBox(message)
@ -1059,6 +1057,25 @@ NavigateFromBaseURLTo(URL,PageTitle := "TodoDeleteme"){
try currentURL := driver.url try currentURL := driver.url
Message = Failed to switch active tab to %URLBase%. Current tab is: %currentURL% Message = Failed to switch active tab to %URLBase%. Current tab is: %currentURL%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
CheckForAlerts()
; create a new tab and try to switch to it again
Message = Creating new tab with URL: %URL%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
try, run "%ChromeFilepath%" "%URL%"
ChromeTabsURLArray.Push(URL) ; Append the new url to the array
NewTabCreated := 1
sleep, 1000
status := ActivateChromeTab(URLBase)
if(Status = "Failed"){
Message = Failed to activate tab for %urlBase% after 2 atteppts. Chrome stuck on a dialog box of some sort?
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return "Failed"
}
} }
; message = ActivateChromeTab Status: %status% ; message = ActivateChromeTab Status: %status%
; DevModeMsgBox(message) ; DevModeMsgBox(message)
@ -1083,16 +1100,14 @@ NavigateFromBaseURLTo(URL,PageTitle := "TodoDeleteme"){
try driver.switchToalert().accept() try driver.switchToalert().accept()
try driver.Get(URL) ;Open selected URL try driver.Get(URL) ;Open selected URL
catch e { catch e {
Message = Failed to Navigate to %URL%: Please Check for Any Open Dialogue Boxes Message = Failed to Navigate to URL: %URL%. Please Check for any open dialog boxes or ChromeDriver being out of date.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return "Failed" Return "Failed"
} }
} }
try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
} }
; msgbox, no error caught
; }
Return Return
} }
@ -1100,7 +1115,7 @@ NavigateFromBaseURLTo(URL,PageTitle := "TodoDeleteme"){
CheckForAlerts(){ CheckForAlerts(){
Message = Checking for Any Obstructing Alerts in Chrome Message = Checking for Any Obstructing Alerts in Chrome
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
status := 1 status := 1
try driver.SwitchToAlert() try driver.SwitchToAlert()
@ -1210,8 +1225,10 @@ SChrome_Get(URL := "", Profile := "Profile 1", IP_Port := "127.0.0.1:9222"){
; Save current chrome version to ini file ; Save current chrome version to ini file
return Driver return Driver
} }
; -------------------------------/SChrome_Get-------------------------------
; -------------------------------/SChrome_Get-------------------------------
/*
*/
ShowSeleniumErrorMsgbox(){ ShowSeleniumErrorMsgbox(){
GetChromeVersionCommand = powershell (Get-Item '%ChromeFilepath%').VersionInfo.ProductVersion GetChromeVersionCommand = powershell (Get-Item '%ChromeFilepath%').VersionInfo.ProductVersion
Chromeversion := RunCMD(GetChromeVersionCommand) Chromeversion := RunCMD(GetChromeVersionCommand)
@ -1281,6 +1298,8 @@ SChrome_Get(URL := "", Profile := "Profile 1", IP_Port := "127.0.0.1:9222"){
/*
*/
; -------------------------------FileXPro Get File Attributes------------------------------- ; -------------------------------FileXPro Get File Attributes-------------------------------
;https://www.autohotkey.com/boards/viewtopic.php?t=59882 ;https://www.autohotkey.com/boards/viewtopic.php?t=59882
@ -1771,7 +1790,8 @@ try status := driver.executeScript(js)
OnMessage(0x44, "OnMsgBoxJSReturnData") OnMessage(0x44, "OnMsgBoxJSReturnData")
MsgBox 0x3,.TextContent:,%status% MsgBox 0x3,.TextContent:,%status%
OnMessage(0x44, "") OnMessage(0x44, "")
/*
*/
IfMsgBox Yes,{ IfMsgBox Yes,{
} Else IfMsgBox No, { } Else IfMsgBox No, {
@ -1789,7 +1809,8 @@ try status := driver.executeScript(js)
OnMessage(0x44, "OnMsgBoxJSReturnData") OnMessage(0x44, "OnMsgBoxJSReturnData")
MsgBox 0x3,.value:,%status% MsgBox 0x3,.value:,%status%
OnMessage(0x44, "") OnMessage(0x44, "")
/*
*/
IfMsgBox Yes,{ IfMsgBox Yes,{
} Else IfMsgBox No, { } Else IfMsgBox No, {
@ -1807,7 +1828,8 @@ try status := driver.executeScript(js)
OnMessage(0x44, "OnMsgBoxJSReturnData") OnMessage(0x44, "OnMsgBoxJSReturnData")
MsgBox 0x3, .innerText,%status% MsgBox 0x3, .innerText,%status%
OnMessage(0x44, "") OnMessage(0x44, "")
/*
*/
IfMsgBox Yes,{ IfMsgBox Yes,{
} Else IfMsgBox No, { } Else IfMsgBox No, {
@ -1826,6 +1848,8 @@ try status := driver.executeScript(js)
OnMessage(0x44, "OnMsgBoxJSReturnData") OnMessage(0x44, "OnMsgBoxJSReturnData")
MsgBox 0x3, .outerText,%status% MsgBox 0x3, .outerText,%status%
OnMessage(0x44, "") OnMessage(0x44, "")
/*
*/
IfMsgBox Yes,{ IfMsgBox Yes,{
@ -1845,6 +1869,8 @@ try status := driver.executeScript(js)
OnMessage(0x44, "OnMsgBoxJSReturnData") OnMessage(0x44, "OnMsgBoxJSReturnData")
MsgBox 0x3, .innerHTML,%status% MsgBox 0x3, .innerHTML,%status%
OnMessage(0x44, "") OnMessage(0x44, "")
/*
*/
IfMsgBox Yes,{ IfMsgBox Yes,{
@ -1864,7 +1890,8 @@ try status := driver.executeScript(js)
OnMessage(0x44, "OnMsgBoxJSReturnData") OnMessage(0x44, "OnMsgBoxJSReturnData")
MsgBox 0x3, .outerHTML,%status% MsgBox 0x3, .outerHTML,%status%
OnMessage(0x44, "") OnMessage(0x44, "")
/*
*/
IfMsgBox Yes,{ IfMsgBox Yes,{
} Else IfMsgBox No, { } Else IfMsgBox No, {
@ -1876,8 +1903,8 @@ IfMsgBox Yes,{
} }
/*
*/
OnMsgBoxJSReturnData() { OnMsgBoxJSReturnData() {
DetectHiddenWindows, On DetectHiddenWindows, On
Process, Exist Process, Exist

Loading…
Cancel
Save