Skip to content
Get Free Trial

Drag and drop issues

Symptom: It seems like Sahi is not able to identify the drag source or drop target. The drag and drop fails.

Resolution: Sometimes you may need to specify a location “inside” the drag source or drop target for the drag/drop to work. We do this by using _xy().

In Sahi, _XY() function specifies the coordinates on element where the event is fired.

Eg. _click(_xy(_button("id"), 10, 20)) clicks inside the button, 10px from the left and 20 pixels from the top.

Negative values can be given to specify offset from right and bottom. Eg. _click(_xy(_button("id"), -5, -10)) clicks inside the button, 5px from the right and 10px from the bottom.

So the _dragDrop code can be written as

_dragDrop(_xy(_span("Source"),10,20),_xy(_div("Target"),10,10));