Drag and Drop

Asked by Jeff_Vallis on 2019-12-31

2.0.1-2019-11-22_16:54/Mac10.15.2/Java13(64)13.0.1+9

Is Drag and Drop Working

def Testing_Drag(dragregion,dropregion,v_Mouse_Delay):
    global g_MoveMouseDelay
    global g_Waterfall_This_Location
    global g_Debug
    print("Do_Drag ")
    v_Wait = 1
    Settings.MoveMouseDelay = v_Mouse_Delay
    hover(dragregion) ; print "hover(dragregion) and Drag",dragregion.x,dragregion.y,"v_Mouse_Delay",v_Mouse_Delay
    print "dropregion",dropregion.x,dropregion.y
    drag(dragregion)
    wait(v_Wait)
    dropAt(dropregion)
    popup(str(v_Mouse_Delay))

g_MoveMouseDelay = 1
v_Try = 0 # Tried diff speeds - worked fine with delay of 5 on 1.1.3
# Get Focus
click(Location(1002, 547))
while v_Try < 100:
    v_Try = v_Try + 1
    Settings.MoveMouseDelay = g_MoveMouseDelay
    dragregion = Location(1071, 588)
    dropregion = Location(630, 537)
    Testing_Drag(dragregion,dropregion,v_Try+4)
    v_Try = 200

Question information

Language:
English Edit question
Status:
Answered
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2019-12-31
Last reply:
2020-01-04
Jeff_Vallis (vallis-pj) said : #1

if this means anything

Running IDE from Terminal
IDE no Errors

Terminal:-
2019-12-31 09:29:10.246 java[17291:527448] -[NSPersistentUIWindowSnapshotter writeWindowSnapshot:length:width:height:bytesPerRow:toFile:inDirectory:encryptingWithKey:uuid:checksum:fd:]: 0 == ftruncate(fd, fileLength) failed on line 874: No such file or directory
2019-12-31 09:30:38.437 java[17291:527766] -[NSPersistentUIWindowSnapshotter writeWindowSnapshot:length:width:height:bytesPerRow:toFile:inDirectory:encryptingWithKey:uuid:checksum:fd:]: 0 == ftruncate(fd, finalFileSize) failed on line 803: No such file or directory
2019-12-31 09:30:38.440 java[17291:527766] -[NSPersistentUIWindowSnapshotter writeWindowSnapshot:length:width:height:bytesPerRow:toFile:inDirectory:encryptingWithKey:uuid:checksum:fd:]: 0 == ftruncate(fd, fileLength) failed on line 874: No such file or directory

after posting above also tried

        mouseDown(Button.LEFT)
        #popup("Am I down")
        wait(0.5)
        #hover(dropregion)
        mouseMove(dropregion)
        wait(0.5)
        mouseUp(Button.LEFT)

you can see the #popup - when active I tried moving mouse it "SEEMED" to drag

TestMechanic (ndinev) said : #2

In my experience I faced some problems with drag and drop on slower (Mac) machines. In order to solve problem a customized function was developed. Note that there are no actions (besides sleep) between all mouse actions

    def CustomDragDropPixels(dragImg, dX=0, dY=0, delay=1):
        hover(dragImg)
        sleep(delay)
        mouseDown(Button.LEFT)
        sleep(delay)
        mouseMove(dX, dY)
        sleep(delay)
        mouseUp(Button.LEFT)
        sleep(delay)

As you can see this is really slow version of drag and drop, but it works :-)

RaiMan (raimund-hocke) said : #4

The standard dragDrop internally works with a delay of 0.3 seconds (Settings.DelayValue)
1. before mouseDown
2. before starting the drag (mouseMove)
3. and before doing the drop (mouseUp)

You may adjust this behaviour generally using the above setting.

Additionally you can adjust each single value for every dragDrop:
1. Settings.DelayBeforeMouseDown
2. Settings.DelayBeforeDrag
3. Settings.DelayBeforeDrop

... but usually the standard works or it is sufficient to raise Settings.DelayValue on slower machines.

BE aware on Mac:
the target application of dragDrop must have focus before you use it.
especially in cases where you have used popups before, that steal the focus.

RaiMan (raimund-hocke) said : #5

This is my test on Mac:

on the Safari favourites page I am moving icons around:

img1 = "img1.png"
img2 = "img2.png"
img3 = "img3.png"
switchApp("safari")
for img in [img1, img2, img3]:
  find(img).highlight(1)
dragDrop(img1, img3) # move it somewhere
wait(1)
dragDrop(img1, img2) # move it back

worked as expected.

Can you help with this problem?

Provide an answer of your own, or ask Jeff_Vallis for more information if necessary.

To post a message you must log in.