是拖和下降可能在的Watir-的webdriver? [英] Is drag-and-drop possible in watir-webdriver?
问题描述
我想一个元素拖动和拖放到另一个位置,从一个的Watir-webdriver的脚本中触发。
通过拖 - 放我的意思是捡了可拖动的元素,并释放它在另一个上。通过可能我的意思是拖/放可从的Watir-webdriver的脚本来执行任何方法。这包括code段,第三方宝石等。
据我了解拖动和下降是核心的Watir-webdriver的(在要求的时间)功能请求,所以我期待(原则)的替代。
更新拖和下降是现在核心的Watir-webdriver的一部分(截至0.5.0,我相信)
更新2 对于那些寻求启迪,这是现在可以(为0.5.0版):
A = browser.div(:ID =>中拖动)
B = browser.div(:ID =>中可弃)a.drag_and_drop_on b
和
A = browser.div(:ID =>中拖动)a.drag_and_drop_by 100,-200
我不知道,如果你发现这个答案现在,但是这是我如何做到这一点Firefox的:
my_element.fire_event(onmousedown事件)
司机= browser.driver
driver.action.click_and_hold(my_element.wd).perform睡眠2
driver.action.move_to(target.wd).perform睡眠2
my_element.fire_event(onmouseup)
它没有没有延迟,但它FF5正常工作与他们。
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.
UPDATE drag-and-drop is now part of core watir-webdriver (as of 0.5.0, I believe)
UPDATE 2 For those seeking enlightenment, this is now possible (as of version 0.5.0):
a = browser.div(:id => "draggable")
b = browser.div(:id => "droppable")
a.drag_and_drop_on b
and
a = browser.div(:id => "draggable")
a.drag_and_drop_by 100, -200
I don't know if you found the answer for this by now, but this is how I do it for Firefox:
my_element.fire_event("onmousedown")
driver=browser.driver
driver.action.click_and_hold(my_element.wd).perform
sleep 2
driver.action.move_to(target.wd).perform
sleep 2
my_element.fire_event("onmouseup")
It fails without the delays, but it works fine with them on FF5.
这篇关于是拖和下降可能在的Watir-的webdriver?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!