使用 watir webdriver,无法按住一个点并移动到连接另一个点,因为没有相同的方法

Using watir webdriver, unable to press & hold a point and move to connecting the other point as there is no method for the same

这是可拖动元素 ->

@browser.div(:class => "start-module-loading").div(:class => 'mod-south').div(:class => 'ui-draggable')

和可放置元素 ->

@browser.div(:class => "syn-module syn-module-green").div(:class => "mod-north").div(:class => 'ui-droppable')

想要将可拖动元素连接到可放置元素。但无法这样做,因为没有执行此操作的方法。我正在使用带有黄瓜的 watir webdriver

您可以使用Element#drag_and_drop_on方法。

draggable = browser.div(id: 'node-866863') # the dot in start
drop_zone = browser.div(id: 'rec-294494')  # the triangle in send sms
draggable.drag_and_drop_on drop_zone

元素 ID 是自动生成的,因此您需要找到一种方法来获取块的相关 dot/triangle。如果您知道正在使用哪些模块,则可以使用 类(和索引)。例如:

draggable = browser.div(id: 'module-0').div(class: 'ui-draggable')
drop_zone = browser.div(id: 'module-1').div(class: 'ui-droppable')
draggable.drag_and_drop_on drop_zone