Class: Capybara::Playwright::Node::SendKeys::PressKey
- Inherits:
-
Object
- Object
- Capybara::Playwright::Node::SendKeys::PressKey
- Defined in:
- lib/capybara/playwright/node.rb
Instance Method Summary collapse
- #execute_for(element) ⇒ Object
-
#initialize(key:, modifiers:) ⇒ PressKey
constructor
A new instance of PressKey.
Constructor Details
#initialize(key:, modifiers:) ⇒ PressKey
Returns a new instance of PressKey.
605 606 607 608 609 610 611 612 613 614 615 616 |
# File 'lib/capybara/playwright/node.rb', line 605 def initialize(key:, modifiers:) # Shift requires an explicitly uppercase a-z key to produce the correct output # See https://playwright.dev/docs/input#keys-and-shortcuts key = key.upcase if modifiers == [MODIFIERS[:shift]] && key.match?(/^[a-z]$/) # puts "PressKey: key=#{key} modifiers: #{modifiers}" if modifiers.empty? @key = key else @key = (modifiers + [key]).join('+') end end |
Instance Method Details
#execute_for(element) ⇒ Object
618 619 620 |
# File 'lib/capybara/playwright/node.rb', line 618 def execute_for(element) element.press(@key) end |