Sikuli gets confused between 2 identical buttons - button

I have identical buttons on the same page and I want Sikuli to click only one of those but it ends up clicking the other name sake button. Unfortunately, the button names cannot be changed. Any suggestions on how I could handle this situation?
Thanks!

You can tell Sikuli to operate on a particular region on the screen relative to a given image/screenshot object. This is called TargetOffset. Refer here assuming you are asking about using sikuli programmatically. From Sikuli IDE, double click on the screenshot image and it brings up a window where you can set accuracy and targetOffset.

If the two icons are close together, and will always appear the same way, and the space between them will always appear the same, then a
click(imageOfTwoIcons).targetOffset(x,y)
is probably the simplest way to go. But, if there is anything that would make this method unreliable (anything between the two icons ever appears differently than when you are making your screen capture of them)--
You could also use the python sorted() function to sort the images by their position. For example, if one image is always above the other, then you could find both images and sort them by their y coordinate, like so:
#a little prep for the sorted function to get the y coord of the icon
def byY(icon):
return icon.y
#findAll() on your two identical icons and make them into a list
bothIcons = list([x for x in findAll(icon)])
#then sort them
sortedIcons = sorted(bothIcons, key=byY)
iconOnTop = sortedIcons[0]
iconOnBottom = sortedIcons[1]
#then click on the one you want
click(iconOnTop) #or save a line and say: click(sortedIcons[0])
The same can be done if you know that the icon of interest is always left or right of its twin:
def byX(yourTwoImages):
return image.x
bothIcons = list([x for x in findAll(icon)])
sortedIcons = sorted(bothIcons, key=byX)
click(sortedIcons[0]) #for the image on the left
I like this better than working with regions if the two icons are very close together on the screen, or if it's possible for the icons' placement to ever change.

you can enlarge the buttons image, so that the image will include more than just the image, but also the background around it (if you can be sure that the background is not changing) but remember that sikuli clicks on the center of the image, so make sure that the button is in the center.
another option is to click using offset (http://doc.sikuli.org/tutorials/checkone/checkone.html)
use something like this:
this.offset = 15;
org.sikuli.script.Region reg = screen.find("image").left(this.offset);
screen.click(reg);

Related

How to combine PrimeFaces InputGroup with an overlay SelectOneButton

I want to build a component, based on InputGroup, with a button that should open a selection. Something more o less like this (please, ignore black border):
When InputGroup p:button A (label '=') is clicked, it opens a p:selectOneButton B, so I can change A value based on B selection.
I have a basic functional script, it can be enhanced, but the simple behavior is accomplished, please fill free to make any improvements/suggestions:
function changeSelectedFilter(evtTarget, tgtButton) {
const op = evtTarget.getJQ().find(':checked').val();
const A = PrimeFaces.getWidgetById(tgtButton);
A.value = op;
A.getJQ().children().text(op);
}
My major issue is with components usage and placement. I'm working with a p:tooltip for now, but it's not what I want, do you have any clues in how to hide/show B correctly placed above A and centered, so it looks like it is been expanded?
With accessibility concerns, this could not be a good approach, and p:menuButton/p:splitButton would be much better, but I want a simple button with just an icon (not default chevron down) and no text...
Here a comparison with p:splitButton and p:menuButton, with desired max-width:
Context: this is a numeric filter component added to columns in p:dataTable, this component current implementation uses a separated p:input and p:selectOneButton, but in 2 lines, so an overlay could optimize space.
Any suggestion with others components will be welcomed too!
Thanks!

Place DataBand in a certain space

Im making a report with Stimulsoft Designer, and I place a lot of information. Now I need to place a data band for showing a list of phones in a certain space, but the only position on which the data band appears is on top (after header) and full width. That's not what I need, I need something like this:
I tried to create a "Data" square, and other options shown there, but it doesn't work. What I'am missing?
The solution is to add a panel with that shape, and insert the databand inside the panel

CSS transition animation with tiles layout is it possible to achieve?

I am trying to create a specific solution for weeks now and I have tried many things but I am just not sure if it is possible at all to achieve. I need your opinions and point me in direction o a correct approach. Following what I am trying to create:
Initially there is a tile layout in which a certain number of cards (say 12) are placed in 4x3 grid:
Now, if user clicks on a tile (Box 3), the state changes to following:
Selected tile is expanded and other tiles get aligned one below another on the right side:
Challenge is that I want to create a transition from every tile's initial state to the state where every tile is aligned one below another on the right. At the same time, when a tile is clicked it is expanded in place.
Note - there are no sudden change in positions, no reload of page and preferably no JS (I wanted to write a CSS-only solution). Everything smoothly animates to new position. From the second screen if a different tile is selected (from right), then the expanded item will shrink and go in to the right hand stack while the selected item will expand and take place of the currently expanded (B3).
If you could just point me to correct direction it would be great help.
thanks.
You should check css flexbox.
Using the "order" proprety, you could asign order of every box from 2 to 8,
and each time a box is selected, you change it's order to 1 and you also change its size and colour.
However, I don't think you can use 'click' actions with css only.
I would recommend using JS for what you are trying to achieve.
Hope it helps

GWT - PopupPanel, change layout when flipped

I'm creating a context menu for certain elements using a PopupPanel; the menu itself is going to be fairly large and complex. What I'm looking to do is to have a list of buttons, plus an image and some text, related to the element clicked.
My problem is that I'd like the buttons to always display directly under the clicked element, because that's convenient for the user; the issue is that when PopupPanel is near the edges of the screen, it automatically changes position to be fully visible, not aligning its left side to the element as usual. I like this behavior, but it moves the position of the buttons away.
So what I'd like to happen is: normally the buttons are on the left of the panel, the other stuff is to the right. When the panel is close to the right of the screen, I'd like the buttons to instead be on the right (and thus under the clicked element) and the other stuff on the left.
Is there a clever way to do this, either in GWT or better yet, using only CSS? PopupPanel itself doesn't seem to tell you when it's going to get flipped, sadly. The only solution I currently have is to manually check the position and width of the popup before showing it and adjust accordingly, but I'm hoping there's a better solution.
Here is what I suggest (based on my own implementation of a similar use case):
Have the position callback implementation accept references (in constructor) on:
PopupPanel element
element on which user right cliked
the content you put in the PopupPanel
Replicate (I know this not DRY but implementation is package private) the code from default position callback
When opening to the right invoke a method that changes the layout of your content (CSS based or otherwise)
I hope it helps. If you find something better let me know.

Prevent overlapping DragDrop Images in Flex

I am trying to create basically a puzzle in Flex Builder 3. I display images from an array onto a canvas that can be dragged and dropped around the canvas. My problem is that I don't want the images to be able to overlap each other. Any ideas on how to prevent this??
They can overlap as you drag but not when dropped, they need to "snap" to the nearest point that is not already occupied by another image.
I did something similar to this. What you do is onDrop add the target (x,x + object.width) and (y,y + object.height) to an array. Prior to this, if array is not null, check to see if your new object's x or y value is within an existing range in the array. If so, do not allow drop else allow the drop. All images, regardless of "picture" are square/rectangles so this would prevent the overlapping. However, if you have complex pictures (i.e. circles/hexagons) and are trying to butt the edges together, then this method will not work.

Resources