drag + dropAt not picked up

Asked by Marianne Murray

Hi!

Running Sikuli script against an app running on the iPhone emulator... and my drag + dropAt does not seem to be picked up properly... Suggestions?

This is the bit of code...
x1, y1, x2, y2 = (200, 250, 200, 575)
start = Location(x1, y1)
end = Location(x2, y2)
drag(start)
dropAt(end)

When i run and show actions i can see the action is what i want, but the mouse being depressed is not being picked up...

thanks!

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Marianne Murray
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

--- The first thing
to try, if keyboard and mouse actions do not work as expected, is to insert some short wait()'s around the actions. This is because for some applications the actions come to fast one after another, to accept them (typical situation with type())

in your case:
drag(start); wait(0.3) # try out the min value needed

--- The second thing
(if first does not help) is to switch to the native methods mouseDown, mouseUp, mouseMove and split the drag-drop into drag - steps of mouseMove along a given or calculated path - drop. If you need this more often, make a def().
(If need help on how to, just come back)

Revision history for this message
Marianne Murray (qualitycurls) said :
#2

It did thanks, but now i have a new question LOL

Revision history for this message
RaiMan (raimund-hocke) said :
#3

no LOL.
That's normal: each discovery raises many new questions (and opportunities ;-)

Your question?

Revision history for this message
Markus (markus-voege) said :
#4

I have the same problem and none of RaiMan suggestions works.

My scripts:

(1)
drag(Location(146, 365)
wait(2)
dropAt(Location(146, 265)

(2)
click(Location(146, 365)
mouseDown(Button.LEFT)
wait(2)
mouseMove(Location(146, 265))
wait(2)
mouseUp(Button.LEFT)

I can see that mouse pointer is moving in the right direction. But it seems to be, that the drag and mouseDown function does not work.
The functions working fine with a scrollbar in a browser.

I'm running an app on an iPhone emulator too.

Any further suggestions?

thanks
Markus

Revision history for this message
RaiMan (raimund-hocke) said :
#5

@Markus

Does your emulator accept normal click() actions and reacts as expected?

Revision history for this message
Markus (markus-voege) said :
#6

@RaiMan

yes it does.

Revision history for this message
RaiMan (raimund-hocke) said :
#7

ok, the you have to try the "along a path method" (background: the mousemove is to fast for your app):

the mouse picks up and moves stepwise along a path between start and end, where it drops.

lets make a def() for that:

def myDragDrop(end, start=None, step=10, t=0):
 if not start: start = Env.getMouseLocation()
 else: mouseMove(start); wait(0.5)
 (sX, sY) = start.x, start.y; (eX, eY) = end.x, end.y
 stX = int(abs(eX-1-sX)/step)
 stY = int(abs(eY-1-sY)/step)
 steps=max(stX, stY)
 stX = int((eX-1-sX)/steps)
 stY = int((eY-1-sY)/steps)
 sX += stX; sY += stY
 mouseDown(Button.LEFT); wait(0.5)
 for i in range(steps):
  mouseMove(Location(sX, sY))
  wait(t)
  sX += stX; sY += stY
 mouseMove(end)
 mouseUp()

usages:
--- mouse already at start: (e.g. hover(someImage))
myDragDrop(to) # to has to be a Location object

--- mouse should be moved to start:
myDragDrop(to, start=Location(someX, someY))

--- use another stepping
myDragDrop(to, step=50) # maximum move 50 pixels each step

--- wait after each move
myDragDrop(to, t=0.2) # waits 0.2 seconds after each move

Revision history for this message
Markus (markus-voege) said :
#8

Heureka!

it works! Thanks a lot!