How to drag the mouse pointer to particular point and drop using sikuli webdriver? - sikuli

Currently, I am working on automating maps. I wanted to select the region using mouse pointer.
find region -> drag mouse pointer -> Drop. Please suggest sikuli webdriver script for this.

There are a couple of built in Sikuli functions: dragDrop() will encompass both the drag and the drop (like the name suggests) Or, you can do the steps separately, if needed (drag(), mouseMove(), dropAt()). These are all in the documentation here.
I don't know much about webdriver or how it interacts with Sikuli, but hopefully its a starting place...

Here is my solution for enlarge a application window. I tested on both windows and linux OS and it work.
corner = find(Pattern('test.png' ).targetOffset(-36,-22))
drop_point = corner.getTarget().offset(dx, dy)
dragDrop(corner, drop_point)
The -36,-22 in function targetOffset(-36,-22)) can be adjust by sikuli IDE.

Here another example:
region1 = find("1429562753142.png")
dropRegion = Location(104,800)
dragDrop(region1, dropRegion)
keyUp()
I defined the reigion where the image is located.
Then I defined the drop region.
By using dragDrop() the image is moved.
And keyUp() is releasing the keys that where being hold down.

Related

How to implement chain search in sikuli script

Can anyone give an advice how to implement using Sikuli analog of Selenium chain element search like driver.findElement().findElement();
first step: finding area
second step find element in this area
Victor Iurkov,
1. You should create a Region and assign to a variable (use Region button from Sikuli IDE panel)
2. Use the variable and apply find() method
It should look like:
yourRegion = Region(2157,169,1049,148)
yourRegion.find("desired-ui-element.png").highlight(2)
Note: Region(2157,169,1049,148) can be created manualy or via Region button in Sikuli IDE

Forge Viewer select element by tapping screen not working correctly on Surface Pro using IE 11 (via cordova)

Using Surface pro touch screen to select element in viewer works sometimes other times it seems to translate to a rotate/zoom action. In this case the viewer rotates/moves and the element is NOT selected.
When logging the events there are plenty of mouse down/up events along with mouse moves when it doesnt work. When select does work a single click event occurs.
Double click seems to work ok.
Zoom/rotate etc using standard tools works ok.
Using the keyboard cover touch pad that you can get for the Surface pro to move and click works as expected and the element is selected.
Running same application on a GETAC Windows 10 ruggadised tablet the select element works correctly so it seems related to the Surface Pro.
Unable to change browsers as cordova apps use IE11 on windows and that is currently fixed.
The only solution i can think of for the moment is to remove the standard navigation tools completely (somehow) and recreate a select mode tool that would ignore any mouse moves and use button down event to select element.
Any suggestions on how to fix this?
Tech Details:
Windows 10 Pro,
Surface Pro,
Browser: IE11,
Viewer version 2.11,
Other: WINJS81 cordova application
Thanks for any help
We've had problems with touch events on the Surface Pro in the past. It sounds like the edges of the touch screen are overly sensitive and are triggering extra touch points.
Does the problem happen if you are holding the device up, gripping with one hand, and using your other hand to touch/select a 3D object ?
Could you try doing a selection again, but this time, make sure you other hand is not holding the edge of the screen? (Perhaps place the device on the surface of a desk, so you are not holding it up)
Found a fix to this issue. In viewer3D in the base toolcontroller there is line
var kClickThreshold = 2;
This value is used further down in code to determine if singleClick has occured. It does it by comparing XY on down and up events.
var deltaX = _downX - event.canvasX;
var deltaY = _downY - event.canvasY;
_downX = -1;
_downY = -1;
if( Math.abs(deltaX) <= kClickThreshold && Math.abs(deltaY) <= kClickThreshold )
_this.handleSingleClick( event );
If movement is above this threshold it does not trigger singleClick if below it does.
Did testing and increasing the value to around 5-7 means that the selection of elements worked consistently. (there is still a minor rotate or zoom at same time as select occurs but I assume that this would be another part of viewer that would need adjusting)
Unfortunately it does require edit of viewer code but easy enough. I added code to overwrite standard value if external variable existed.
Would be nice for future viewer dev if more of these types of properties be exposed so that direct edit of code is not required.
Still it is good to have the source code to be able to debug at this level.
At a guess the Surface Pro 4 must have a more sensitive touch system or it could just be related to IE11 as well.

Map pinning in react native

I am looking for a way to capture user click and create a pin on the map view. Does anyone has any idea where can I start, I was not able to find anything.
There are two solutions for your issue.
Using RN's native MapView component, there are no easy solutions. You can create a pin when `onRegionChangeComplete is triggered. But you'll get the coordinates of the center of the map only. I've set up a running example for you here.
You can use this very well done package. In this package, there is an onPress method that you can use. It'll return you the coordinate of the point you just pressed.
You should look at the onRegionChange prop from the MapView component. That's a function that will be triggered whenever the user drags the map. Between that and the annotations props you should be able to achieve what you want.

How can I select and drag a line in canvas?

I'm now working on a painting app. It uses a html canvas. Users can draw shapes on the canvas.
Now a problem comes to me. I want to select the line that I drew on the canvas. When it is selected, I can drag it or delete it. How can I implement it ? Any good ideas?
It might be worth your while to have a look at https://github.com/canvimation/canvimation.github.com this contains the source code for a drawing application using canvas.
You should note that this application is being re-coded but there is not yet a working version using the new code on line. The new source code is in the stage1 branch. Hopefully this new code is easier to understand than the old code and the code referred to below comes from the stage1 branch.
Basically a shape object is created for each shape drawn which includes all data about eh shape, including path data and data giving the rectangular boundary around the shape. When the "boundarydrop" div is clicked then function checkBoundary is called and data about the shift key and cursor position are passed. Then for each shape the first check is to see if the cursor is within the boundary of the shape and if so then a more refined check is carried out. For a closed shape the check is if the cursor in inside the shape and for an open shape if the cursor is close to the path.
There are further complications depending whether the shift key is held down or not and which group the shape belongs to. However the basics are there.
Functions to check out
in index.html
shiftdown
getPosition
in scripts/drawboundary.js
checkBoundary
isIn
isOn
in scripts/shape.js
shape
A working online version of the application is at http://canvimation.github.com/ but this uses the older code in the master branch and there are some bugs but it will give you some idea of what the application does.
Hope this is of some help
There is a library called kinetic.js, with it you can keep track of the shapes you draw on the canvas with the select feature.
Here is the link: https://github.com/ericdrowell/KineticJS

Open info window if user hovers longer than x milliseconds

What I'm trying to do is very simple:
open the marker's info window only if the user has hovered on the marker for longer than x millisecond.
I can't find how to do this anywhere. I would appreciate a little code snippet to show me how to set this up!
The jQuery HoverIntent plugin might be able to help you
http://cherne.net/brian/resources/jquery.hoverIntent.html
hoverIntent is a plug-in that attempts to determine the user's intent... like a crystal ball, only with mouse movement! It works like (and was derived from) jQuery's built-in hover. However, instead of immediately calling the onMouseOver function, it waits until the user's mouse slows down enough before making the call.
Actually I finally found the solution to it on the Google Maps Group here: http://groups.google.com/group/google-maps-api/browse_thread/thread/73cf193d42a0bbfe/fa531a39b353d198?lnk=gst&q=open+hover#fa531a39b353d198
Best of luck to all the late night coders out there :)