Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Browser Detach Bug #82

Open
GCuser99 opened this issue Jun 6, 2023 · 0 comments
Open

Browser Detach Bug #82

GCuser99 opened this issue Jun 6, 2023 · 0 comments

Comments

@GCuser99
Copy link
Owner

GCuser99 commented Jun 6, 2023

A very strange bug occurs when combining the browser detach option of WebCapabilities class with a command window style that is NOT vbHide or vbMinimizedNoFocus. If any one of the other command window styles is used, then the browser closes on shutdown. Happens with both Chrome and Edge...

Sub test_detach_browser()
    'use this if you want browser to remain open after shutdown clean-up - only for Chrome/Edge
    Dim driver As SeleniumVBA.WebDriver
    Dim caps As SeleniumVBA.WebCapabilities
    
    Set driver = SeleniumVBA.New_WebDriver
    
    'for detach to function properly, must use either vbHide (Default) or vbMinimizedNoFocus
    'driver.CommandWindowStyle = vbHide '<-- this works fine
    driver.CommandWindowStyle = vbNormalFocus '<-- using this will close the browser on shutdown
    
    driver.StartChrome
    
    Set caps = driver.CreateCapabilities(initializeFromSettingsFile:=False)
    
    'this sets whether browser is closed (false) or left open (true)
    'when the driver is sent the shutdown command before browser is closed
    'defaults to false
    'only applicable to edge/chrome browsers
    caps.SetDetachBrowser True
    
    driver.OpenBrowser caps
    
    driver.NavigateTo "https://www.wikipedia.org/"
    
    driver.Wait 1000
    
    'driver.CloseBrowser 'detach does nothing if browser is closed properly by user
    driver.Shutdown
End Sub
GCuser99 added a commit that referenced this issue Oct 23, 2023
WebCapabilities class:
    - Added AddLocalStateFlags method to WebCapabilities class as a shortcut for adding experimental browser flags - Chrome/Edge only [@Silver-Surfer, #63]
    - Added Error handling to SetDetachBrowser method to solve issue #82
    - Added Friend property Get CommandWindowStyle to WebDriver class for use in SetDetachBrowser error handling
WebDriver class:
    - Added SetDownloadFolder method for setting download folder w/o needing to set in capabilities - Chrome/Edge only
    - Added "Set lastElems = Nothing" to Shutdown method so that terminate event of WebDriver class fires
WebDriver/WebElement classes:
    - Added maxWaitTimeMS argument/functionality to IsDisplayed, IsSelected, and IsEnabled methods
ActiveX DLL solution:
    - Removed Err.Raise bug work-around after bug fixed in twinBASIC compiler
    twinBASIC banner (at least for now) no longer displays for 5 secs at startup
    - Added 32-bit support for >= Office 2010
Minor Code Cleanups
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant