Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drag and drop with Sikuli

I am having trouble using drag and drop with Sikuli. I would like to drag something in any other direction (up, down, left, right) for a fixed number of pixels.

This looks like it should work:

t = find("1325249963143.png")
dragDrop(t, [t.x + 100, t.y + 100])

Sikuli IDE log says

[log] DRAG (741,525) to null

but the element is not dragged.

This works just fine:

dragDrop("1325249963143.png", "1325251471990.png")

The log says

[log] DRAG (741,525) to (507,490)

What am I doing wrong?

Environment: Mac OS X 10.7.2, Sikuli X-1.0rc3 (r905)

like image 904
Željko Filipin Avatar asked Dec 30 '11 13:12

Željko Filipin


People also ask

Can you compare two images with Sikuli?

Ideally Sikuli works if you already have an image that your comparing against what's found on the screen. Below I dynamically create a region, then snap a picture, and finally compare the saved picture against what in the dynamically created region.

What is the use of Sikuli in selenium?

Sikuli is commonly used with selenium web driver automation tool to overcome some limitations of selenium web driver. 1. Selenium web driver does not support Flash Objects. But Sikuli provides good support to automate flash objects.

How do I use Sikuli in Python?

You can run SikuliX scripts using <path-to-jython>/bin/jython <path-to-youNameIt. sikuli>/youNameIt.py . In a Python IDE you have to setup your project according to the rules.

How do I drag to the left in Sikuli?

It is also possible to use relative coordinates to explicitly drag to the left, as shown below. Here, the (x,y) coordinates of the slider thumb are accessible as the attributes of t. We can thus calculate the position 200 pixels to the left of t and ask Sikuli Script to drag the thumb to that position.

How to use the classes provided by Sikuli?

Once you have added the JAR file to project build path, classes provided by Sikuli can be used. Screen class is the base classes for all the methods provided by Sikuli. Screen class contains predefined methods for all the commonly performed operations on screen elements such as click, double-click, providing input to a text box, hover, etc.

How does Sikuli work in Firefox?

Sikuli looks for all elements that fall within the specified similarity range and returns a new pattern object. This method returns a new pattern object with similarity set to 1. It looks only for an exact match of the specified element. Below code explains the use of Sikuli for file upload in Firefox.

How to add images to your Sikuli project?

Step #1) Take the screenshot of the required items on the screen, and put it inside your Sikuli project. [ Note: here, downloads icon is “source.png” and flower image is “destination.png”] Step #2) Put these pictures inside your project.


2 Answers

only to say hello here - an alternative coding:

dragDrop(t, t.offset(Location(100, 100)))
like image 159
RaiMan Avatar answered Sep 30 '22 05:09

RaiMan


To quote RaiMan (raimund-hocke):

the first parameter is a Match object, which is ok. the second prameter must be of type PSMRL too (see docs: Pattern/Image, String, Match, Region or Location)

dragDrop(t, Location(t.x + 100, t.y + 100))
like image 23
Željko Filipin Avatar answered Sep 30 '22 06:09

Željko Filipin