Class: Capybara::Playwright::Node::DragTo
- Inherits:
-
Object
- Object
- Capybara::Playwright::Node::DragTo
- Defined in:
- lib/capybara/playwright/node.rb
Constant Summary collapse
- MODIFIERS =
{ alt: 'Alt', ctrl: 'Control', control: 'Control', meta: 'Meta', command: 'Meta', cmd: 'Meta', shift: 'Shift', }.freeze
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(page, source, target, options) ⇒ DragTo
constructor
A new instance of DragTo.
Constructor Details
#initialize(page, source, target, options) ⇒ DragTo
Returns a new instance of DragTo.
649 650 651 652 653 654 |
# File 'lib/capybara/playwright/node.rb', line 649 def initialize(page, source, target, ) @page = page @source = source @target = target @options = end |
Instance Method Details
#execute ⇒ Object
656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 |
# File 'lib/capybara/playwright/node.rb', line 656 def execute @source.scroll_into_view_if_needed # down position_from = center_of(@source) @page.mouse.move(*position_from) @page.mouse.down @target.scroll_into_view_if_needed # move and up sleep_delay position_to = center_of(@target) with_key_pressing(drop_modifiers) do @page.mouse.move(*position_to, steps: 6) sleep_delay @page.mouse.up end sleep_delay end |