diff options
-rw-r--r-- | spec/support/helpers/drag_to_helper.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/spec/support/helpers/drag_to_helper.rb b/spec/support/helpers/drag_to_helper.rb index 6099f87323f..6883f8afe8b 100644 --- a/spec/support/helpers/drag_to_helper.rb +++ b/spec/support/helpers/drag_to_helper.rb @@ -2,7 +2,21 @@ module DragTo def drag_to(list_from_index: 0, from_index: 0, to_index: 0, list_to_index: 0, selector: '', scrollable: 'body', duration: 1000) - evaluate_script("simulateDrag({scrollable: $('#{scrollable}').get(0), duration: #{duration}, from: {el: $('#{selector}').eq(#{list_from_index}).get(0), index: #{from_index}}, to: {el: $('#{selector}').eq(#{list_to_index}).get(0), index: #{to_index}}});") + js = <<~JS + simulateDrag({ + scrollable: $('#{scrollable}').get(0), + duration: #{duration}, + from: { + el: $('#{selector}').eq(#{list_from_index}).get(0), + index: #{from_index} + }, + to: { + el: $('#{selector}').eq(#{list_to_index}).get(0), + index: #{to_index} + } + }); + JS + evaluate_script(js) Timeout.timeout(Capybara.default_max_wait_time) do loop while drag_active? |