Vatir - drag not working

I need to check some functionality where I need to drag and drop some UI elements.

I tried to do it on this page http://www.html5rocks.com/en/tutorials/dnd/basics/ :

browser.divs(:class => "column")[-2].drag_and_drop_on browser.divs(:class => "column")[-3]

      

In chrome, I don't see anything happening. In firefox, I can see that the mouse button is not working, but nothing else happens - the element hasn't moved. I tried on other pages as well and it never worked.

I've also tried this workaround (which is recommended across multiple threads) and it doesn't work either:

my_element = browser.divs(:class => "column")[-4]
target = browser.divs(:class => "column")[-3]
my_element.fire_event("onmousedown")
driver = browser.driver
driver.action.click_and_hold(my_element.wd).perform
driver.action.move_to(target.wd).perform
target.fire_event("onmouseup")

      

I am using ruby ​​1.9.3 on mac. I also tried ruby ​​2.1.5 on windows and the result was the same.

Is there a way to drag and drop using watir?

+3


source to share


1 answer


This is what ultimately got him to work (not a fantasy at all, but he did it for me):



# monkey patch for webdriver: copy and paste in IRB
module Selenium
  module WebDriver
    class ActionBuilder
      def drag_and_drop(source, target)
        click_and_hold source
        move_to        target, 0, 0
        release        target

        self
      end
    end # ActionBuilder
  end # WebDriver
end # Selenium

      

0


source







All Articles