6

I would like to drag-and-drop one element to the position of another, triggered from within a watir-webdriver script.

By "drag-and-drop" I mean picking up a draggable element and releasing it on another. By "possible" I mean any method for drag/drop that can be executed from a watir-webdriver script. This includes code snippets, third party gems, etc.

As I understand it drag-and-drop is a feature request for core watir-webdriver (at time of asking), so I'm looking (in principle) for an alternative.

  • 2
    This Selenium TipsAndTricks page suggests it is possible to implement drag-and-drop on top of webdriver (Firefox but not IE): code.google.com/p/selenium/wiki/TipsAndTricks. – user246 Jun 27 '11 at 15:40
  • The best venue for technical questions regarding Watir or associated gems like watir-webdriver is the main StackOverflow site – Chuck van der Linden Jun 27 '11 at 22:34
  • Yeah I do wish QA would migrate to SQA&T. Thanks for the advice, though, I shall do a crosspost of victory. – kinofrost Jun 28 '11 at 8:19
4

This is how I'm doing drag and drop in watir-webdriver. This only works in Firefox:

browser.div(:text=>"from_div").wd.drag_and_drop_on(browser.div(:text=>"to_div").wd)

|improve this answer|||||
  • Many thanks. Should be noted for other users that wd is part of the private API so shouldn't be used for large projects that cannot maintain a change to it. Luckily I'll use whatever I can get, and for non-IE testing this may prove very useful – kinofrost Jun 28 '11 at 8:17
  • Still in today, it is working in firefox, but not in chrome! Is there a consistent fix for drag_and_drop_on/drag_and_drop_by in chrome? – Nawshad Rehan Rasha Oct 30 '18 at 5:29
2

I've done something similar using events and/or autoit.. don't recall off the top of my head what the solution was (would need to go back and find that code)

I'd recommend asking on the main StackOverflow site and tag the question with Watir and Watir-webdriver.. a lot more of the Watir folks watch that site than this one

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.