; if only 1 tab exists, grab info, push to array and exit early
; if only 1 tab exists, grab info, push to array and exit early
if(TotalTabsFound = 1){
if(TotalTabsFound = 1){
@ -813,7 +814,7 @@ CreateArrayOfTabs() {
StartTime := A_TickCount
StartTime := A_TickCount
Loop, {
Loop, {
Message = Creating an Array of All Chrome Tabs`nCurrent Loop: %A_index%/%TotalTabsFound% (Cannot loop through unloaded tabs)`nSometimes might get stuck for a short while if there is something loading in active tab
Message = Creating an Array of All Chrome Tabs`nCurrent Loop: %A_index%/%TotalTabsFound%`nSometimes might get stuck for a short while if there is something loading in active tab
loop % NumberOfTabLoops { ; loop through tabs to find matching tab
loop % NumberOfTabLoops {
try driver.SwitchToNextWindow()
try driver.SwitchToNextWindow()
; sleep, 1000
; sleep, 1000
; msgbox, looping through tabs
; msgbox, looping through tabs
try CurrentTabTitle := driver.window.title
try CurrentTabTitle := driver.window.title
try CurrentTabURL := driver.Url
; DevModeMsgBox(CurrentTabURL)
; DevModeMsgBox(CurrentTabTitle)
; caused by tab being manually closed. Not sure if this is the only cause though.
; caused by tab being manually closed. Not sure if this is the only cause though.
if(CurrentTabTitle = "") {
if(CurrentTabTitle = "") {
Message = CurrentTabTitle: %CurrentTabTitle%
Message = CurrentTabTitle: %CurrentTabTitle%
DevModeMsgBox(Message)
; DevModeMsgBox(Message)
Message = CurrenttabURL: %CurrentTabURL%
Message = CurrenttabURL: %CurrentTabURL%
DevModeMsgBox(Message)
; DevModeMsgBox(Message)
; try driver.SwitchToNextWindow
; try driver.SwitchToNextWindow
Continue
Continue
}
}
try CurrentTabURL := driver.Url
if(InStr(CurrentTabURL, URLBase)){
if(InStr(CurrentTabURL, URLBase)){
; msgbox, found it.`n%CurrentTabTitle% = %PageTitle%`n%CurrentTabURL% = %URLBase%
; msgbox, found it.`n%CurrentTabTitle% = %PageTitle%`n%CurrentTabURL% = %URLBase%
TabFoundSuccessfully := 1
TabFoundSuccessfully := 1
; msgbox %CurrentTabTitle% = %PageTitle%
; message = %CurrentTabTitle%: %PageTitle%
; DevModeMsgBox(message)
; msgbox %CurrentTabURL% = %URL%
; msgbox %CurrentTabURL% = %URL%
Break
Break
}
}
}
}
; if failed to switch to tab and a new tab was not created, then chrome failed to switch to the tab
; this happens sometimes. most likely to a chromedriver bug or maybe tab being offloaded?
if(!TabFoundSuccessfully AND !NewTabCreated){
; @todo : not sure how to best solve this problem currently. It doesn't happen very often.
; last time it happened was when there were only 2 chrome tabs open, gab + subscribestar. chrome was stuck on subscribestar page and wouldn't nextwindow() to gab