Class: Booth::Testing::Support::VirtualAuthenticators::Enable

Inherits:
Object
  • Object
show all
Includes:
Logging, Calls, Capybara::DSL
Defined in:
lib/booth/testing/support/virtual_authenticators/enable.rb

Overview

Start the Virtual Authenticator Environment in Chrome.

Instance Method Summary collapse

Instance Method Details

#callObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/booth/testing/support/virtual_authenticators/enable.rb', line 13

def call
  log { 'Ensuring enabled Chrome Virtual Authenticator Environment...' }
  # The Environment *randomly* leaks from test to test, disabling it first works.
  # This happens with both Selenium and Playwright.
  # All you'll see is `NotAllowedError` in the JS console if you miss this.
  page.driver.with_playwright_page do |playwright_page|
    cdp_session = playwright_page.context.new_cdp_session(playwright_page)

    # log { '[WebAuthn] Disabling any existing environment...' }
    # disable_result = cdp_session.send_message('WebAuthn.disable')
    # log { "[Disable result: #{disable_result.inspect}" }

    # log { '[WebAuthn] Enabling virtual authenticator environment...' }
    cdp_session.send_message('WebAuthn.enable')
    # log { "[Enable result: #{enable_result.inspect}" }

    # log { '[WebAuthn] Virtual Authenticator Environment is ready' }
  end
end