Class: Capybara::NodeActionsAllowLabelClickPatch::SelectableElementHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/capybara/playwright/node.rb

Instance Method Summary collapse

Constructor Details

#initialize(node:, node_type:, locator:, checked:) ⇒ SelectableElementHandler

Returns a new instance of SelectableElementHandler.



35
36
37
38
39
40
# File 'lib/capybara/playwright/node.rb', line 35

def initialize(node:, node_type:, locator:, checked:)
  @node = node
  @node_type = node_type
  @locator = locator
  @checked = checked
end

Instance Method Details

#set_checked_state_via_label?Boolean

Returns:

  • (Boolean)


42
43
44
45
46
47
48
49
50
# File 'lib/capybara/playwright/node.rb', line 42

def set_checked_state_via_label?
  playwright_checkable = find_playwright_element_handle_by_non_label_locator
  playwright_checkable ||= playwright_locator_by_label unless @locator.nil?
  return false unless playwright_checkable

  click_associated_label?(playwright_checkable)
rescue Capybara::ElementNotFound, Capybara::ExpectationNotMet, ::Playwright::Error
  false
end