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(){
try Driver := SChrome_Get("", ChromeProfile := "") ; open new tab page with with specified profile
catch e {
@ -790,6 +770,9 @@ SeleniumConnectToActiveTab(IP_Port := "127.0.0.1:9222"){
return Driver
}
/*
*/
CreateArrayOfChromeTabs() {
Message = Creating an Array of All Chrome Tabs
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
@ -895,9 +878,11 @@ CreateArrayOfChromeTabs() {
return
}
/*
*/
InputFilePathIntoOpenWindow(Filepath){
; Msgbox % "Filepath: " Filepath
Message = Waiting for "Open" window to appear to input filepath into
@ -969,6 +954,10 @@ ActivateChromeTab(URL){
; NumberOfTabLoops := Driver.Windows.Count + 2
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()
; sleep, 1000
@ -1014,8 +1003,12 @@ return "Failed"
NavigateFromBaseURLTo(URL,PageTitle := "TodoDeleteme"){
if(!DriverStatus){ ; if not connected to selenium chrome, then re-connect
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"
}
; CreateArrayOfChromeTabs() ; moved to the end of checkseleniumdriver()
}
@ -1044,11 +1037,16 @@ NavigateFromBaseURLTo(URL,PageTitle := "TodoDeleteme"){
if(!HasSubstringVal(ChromeTabsURLArray, URLBase))
{
; DevModeMsgBox("Creating new tab")
Message = Tab for %urlBase% does not exist. Creating new tab with URL: %URL%
try, run "%ChromeFilepath%" "%URL%"
ChromeTabsURLArray.Push(URL) ; Append the new url to the array
NewTabCreated := 1
sleep, 1000
}
else, {
Message = %URLBase% is within ChromeTabsURLArray. Trying to Activate.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
}
; message = NewTabCreated: %NewTabCreated%
; DevModeMsgBox(message)
@ -1059,6 +1057,25 @@ NavigateFromBaseURLTo(URL,PageTitle := "TodoDeleteme"){
try currentURL := driver.url
Message = Failed to switch active tab to %URLBase%. Current tab is: %currentURL%
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%
; DevModeMsgBox(message)
@ -1083,16 +1100,14 @@ NavigateFromBaseURLTo(URL,PageTitle := "TodoDeleteme"){
try driver.switchToalert().accept()
try driver.Get(URL) ;Open selected URL
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")
Return "Failed"
}
}
try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
}
; msgbox, no error caught
; }
Return
}
@ -1100,7 +1115,7 @@ NavigateFromBaseURLTo(URL,PageTitle := "TodoDeleteme"){
CheckForAlerts(){
Message = Checking for Any Obstructing Alerts in Chrome
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
status := 1
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
return Driver
}
; -------------------------------/SChrome_Get-------------------------------
; -------------------------------/SChrome_Get-------------------------------
/*
*/
ShowSeleniumErrorMsgbox(){
GetChromeVersionCommand = powershell (Get-Item '%ChromeFilepath%').VersionInfo.ProductVersion
Chromeversion := RunCMD(GetChromeVersionCommand)
@ -1281,6 +1298,8 @@ SChrome_Get(URL := "", Profile := "Profile 1", IP_Port := "127.0.0.1:9222"){
/*
*/
; -------------------------------FileXPro Get File Attributes-------------------------------
;https://www.autohotkey.com/boards/viewtopic.php?t=59882
@ -1771,7 +1790,8 @@ try status := driver.executeScript(js)
OnMessage(0x44, "OnMsgBoxJSReturnData")
MsgBox 0x3,.TextContent:,%status%
OnMessage(0x44, "")
/*
*/
IfMsgBox Yes,{
} Else IfMsgBox No, {
@ -1789,7 +1809,8 @@ try status := driver.executeScript(js)
OnMessage(0x44, "OnMsgBoxJSReturnData")
MsgBox 0x3,.value:,%status%
OnMessage(0x44, "")
/*
*/
IfMsgBox Yes,{
} Else IfMsgBox No, {
@ -1807,7 +1828,8 @@ try status := driver.executeScript(js)
OnMessage(0x44, "OnMsgBoxJSReturnData")
MsgBox 0x3, .innerText,%status%
OnMessage(0x44, "")
/*
*/
IfMsgBox Yes,{
} Else IfMsgBox No, {
@ -1826,6 +1848,8 @@ try status := driver.executeScript(js)
OnMessage(0x44, "OnMsgBoxJSReturnData")
MsgBox 0x3, .outerText,%status%
OnMessage(0x44, "")
/*
*/
IfMsgBox Yes,{
@ -1845,6 +1869,8 @@ try status := driver.executeScript(js)
OnMessage(0x44, "OnMsgBoxJSReturnData")
MsgBox 0x3, .innerHTML,%status%
OnMessage(0x44, "")
/*
*/
IfMsgBox Yes,{
@ -1864,7 +1890,8 @@ try status := driver.executeScript(js)
OnMessage(0x44, "OnMsgBoxJSReturnData")
MsgBox 0x3, .outerHTML,%status%
OnMessage(0x44, "")
/*
*/
IfMsgBox Yes,{
} Else IfMsgBox No, {
@ -1876,8 +1903,8 @@ IfMsgBox Yes,{
}
/*
*/
OnMsgBoxJSReturnData() {
DetectHiddenWindows, On
Process, Exist

Loading…
Cancel
Save