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)
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.
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.
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.
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.
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.
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.
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.
only to say hello here - an alternative coding:
dragDrop(t, t.offset(Location(100, 100)))
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))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With