twalpole / apparition

Capybara driver for Chrome using CDP
MIT License
363 stars 46 forks source link

Window management not working /window handles not returned when headless=false #70

Closed jhirn closed 3 years ago

jhirn commented 3 years ago

Hello 👋

Was having some trouble getting #switch_to_window working when migrating to this gem. Turns out even though the new window is opening, page.driver.browser.window_handles size is still 1 and it's as if the driver is unaware of the 2nd tab. I later tried to migrate to the newer Capybara #window_opened_by, but the block would never return the window and hang indefinitely (even if specifying wait: 1). If I would close the tab manually, the block would exit with an error expected block to open 1 windows but 0 were opened.

I was able to replicate this within the Apparition spec suite by setting headless: false in the spec helper and executing

bundle exec rspec spec/integration/session_spec.rb:649

  1) Capybara::Session with apparition driver Window support #size should switch to original window if invoked not for current window
     Failure/Error:
       @other_window = @session.window_opened_by do
         @session.find(:css, '#openWindow').click
       end

     Capybara::WindowError:
       block passed to #window_opened_by opened 0 windows instead of 1

This test doesn't fail indefinitely like mine did, but the error is consistent. I was also able to fix my suite by going back to headless: true. SImilarly, I have this same problem with the Cuprite driver as I'm evaluating both at this time. It may be something with a recent CDP update. Here's some machine info:

OS: Mac OS Big Sur 11.0.1 Google Chrome: Version 87.0.4280.88

twalpole commented 3 years ago

I'm sorry I haven't had any time to give apparition the attention it needs, and have prioritized the small amount of free time I have had to Capybara. I'm willing to look at any PRs here but beyond that don't know when I'll be able to put more time towards apparition.