0

I'm writing a test which runs over Cuprite::Ferrum, where I need to click, drag and drop an element below another element on the page. Which works fine while I am doing it manually, but when i try to put it in a test, it almost work, but not quite.

I was unable to find he drag and drop API for Ferrum or Cuprite, so I created something like:

  def click_and_drag(draggable, droppable, offset_x, offset_y)
    x1, y1 = draggable.native.node.find_position
    x2, y2 = droppable.native.node.find_position

    mouse = page.driver.browser.mouse
    mouse.move(x: x1, y: y1)
    mouse.down
    mouse.move(x: x2 + offset_x, y: y2 + offset_y)
    mouse.up
  end

Pretty simple and works fine until it get to the mouse.up part. The element that needs to be picked up is found by the draggable = page.find(element), and it needs to be dropped below the droppable = page.find(element).

Everything is going great until the method gets to the mouse.up part, where the dragged element should be dropped and put in it's new place, but it just goes back to it starting position.

I am referring to the Ferrum doc https://www.rubydoc.info/gems/ferrum/0.5/Ferrum/Mouse but cant seam to find the answer.

DrCaputto
  • 1
  • 4

1 Answers1

0

So, the method works and all is well, the problem was with offset_x and offset_y, if you somehow find this and want to use it, keep it in mid, and keep them small!

DrCaputto
  • 1
  • 4