Class: Booth::Testing::Support::VirtualAuthenticators::Create

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

Instance Method Summary collapse

Instance Method Details

#callObject



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

def call
  log { "Adding Virtual Authenticator... #{options.as_json}" }
  result = nil
  page.driver.with_playwright_page do |playwright_page|
    cdp_session = playwright_page.context.new_cdp_session(playwright_page)
    log { '[WebAuthn] Sending addVirtualAuthenticator command...' }
    result = cdp_session.send_message('WebAuthn.addVirtualAuthenticator', params: { options: options })
    log { "[WebAuthn] addVirtualAuthenticator result: #{result.inspect}" }
  end
  authenticator_id = result['authenticatorId']
  if authenticator_id
    log { "[WebAuthn] ✓ Virtual Authenticator created with ID: #{authenticator_id}" }
  else
    log { "[WebAuthn] ✗ FAILED to create Virtual Authenticator - no authenticatorId in response" }
  end
  authenticator_id
end