Skip to content

How to check "no such window: target window already closed" in VBA code? #96

Closed Answered by GHRyunosuke
GHRyunosuke asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks a lot, @6DiegoDiego9 and @GCuser99. I think I will take the easier approach combining both your advice as follows to handle this situation.

Sub NavigateToFailsafe(driver As WebDriver, strURL As String)

    On Error Resume Next
    driver.NavigateTo strURL
    
     If Err.Number <> 0 Then
        driver.CloseBrowser
        driver.OpenBrowser
        driver.NavigateTo strURL
     End If
     
    On Error GoTo 0
    
End Sub

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by GHRyunosuke
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants