Jump to content

Webdriver - Detecting a webdriver chrome instance shut down


NassauSky
 Share

Go to solution Solved by Danp2,

Recommended Posts

Hi @Danp2 and all,

Case scenario:

User1 manually opens chrome and logs into website A (instance 1 of chrome)

User1 starts an autoit script with webdriver UDF which it opens chrome and logs into website B (without closing instance 1 of chrome)

User1 manually closes that 2nd instance

How can I have Autoit sense that 2nd instance of chrome was shutdown and display a msgbox?

Edited by NassauSky
Link to comment
Share on other sites

  • NassauSky changed the title to Webdriver - Detecting a webdriver chrome instance shut down

@Danp2 You read my mind. I was just posting: (This does not detect $sSession being removed)

 

Global $sSession = _WD_CreateSession($sDesiredCapabilities)
    ;Global $sID = _WD_GetSession($sSession) ; Test but doesn't work
    If @error Then
        ConsoleWrite("Error creating WebDriver session: " & @error & @CRLF)
        Exit
    EndIf

    Global $handleTitle = _WD_Action($sSession, 'title')
    Global $Handle = WinGetHandle($handleTitle)
    Global $aHandlePos = WinGetPos($Handle)

ConsoleWrite("!Initial $sSession: " & $sSession & @CRLF)
;ConsoleWrite("!Initial $sSessionID: " & $sSessionID & @CRLF) ; Doesn't work
_WD_Navigate($sSession, "https://learnwebcode.github.io/practice-requests/") 
AdlibRegister("_CheckForChromeClose",1000)

While 1
    Sleep(20)
Wend
_WD_DeleteSession($sSession)
_WD_Shutdown()

Func _CheckForChromeClose()
    ConsoleWrite("$sSession: " & $sSession & " / " )
    ;ConsoleWrite("$sSessionID: " & $sID & @CRLF)
;~  If StringLen($sSession)=0 Then
;~      MsgBox($MB_TOPMOST, "Session Closed", "The WebDriver session has been closed.")
;~      Exit
;~  EndIf
EndFunc

 

Edited by NassauSky
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...