Last Updated: February 25, 2016
·
1.159K
· gouravtiwari

Drag and drop feature WatirWebdriver

browser = Watir::Browser.new :firefox

elementToPick = browser.div(:id => 'elementToPickId')
elementToCollect = browser.a(:id => 'elementToCollectId')

elementToPick.fire_event("onmousedown")
driver=browser.driver
driver.action.click_and_hold(elementToPick.wd).perform
sleep 2
driver.action.move_to(elementToCollect.wd).perform
sleep 2
elementToCollect.fire_event("onmouseup")