very weird behavior with dragAndDropBy(), dragAndDrop(), moveToElement, etc - java

Not sure if its due to how the application im automating has its UI set up but what Im trying to do is open up a side drawer that holds a couple table rows. I need to drag a table row into another specific area and drop it there to move it.
So heres an Idea of what the interface looks like:
NOTE: All that whitespace is not a valid area to drop the table row the tablerows are only droppable in a very specific area that becomes visible when the tablerow is right above it.
Im trying to drag the items on the right hand drawer to the left hand side.
When I try to use dragAndDropBy to move to the respective x and y offsets it looks like it doesnt move to the correct location.
I have modified my code now to at least help me see whats wrong and it seems like its not moving to the x coordinate set in my code below:
Actions actions = new Actions(driver);
System.out.println(productArrangement.getLocation());
actions.clickAndHold(productArrangement).moveByOffset(-408, 308).perform();
System.out.println(productArrangement.getLocation());
Thread.sleep(4000);
As you guys can see all this is trying to do at the moment is see where my element is being moved too and logging if the element is actually moving to the respective direction and it seems like its not being moved at the x coordinate and is moving at the wrong Y coordinate(but at least its moving).
here is my console
I would expect the second coordinate log to have moved to the specified offSets I put in but I have gotten similar behavior for all the methods I've tried so far.
Please advise assistance would be greatly appreciated.

Use direct dargAndDrop method like below:
Actions actions = new Actions(driver);
actions.dragAndDropBy(productArrangement,-408, 308).perform();

Related

JavaFX elements aligning right before animating

I'm developing a small GUI using JavaFX for an assignment. Having never used JavaFX before, most of what I've used or learned I've research myself. Most of my application runs smoothly, animations included.
I have a small user input section:
I'm trying to allow it to swipe left prior to loading the next scene, to give the user the impression of sequence. I achieved this using a ParallelTransition populated by TranslationTransitions in which I load all of these Nodes.
However, just slightly before it animates, it appears to align everything right.
I have a feeling this is something to do with the container (AnchorPane) in which I'm placing these objects, or some undefined attribute which I'm not setting. As I'm learning this all on the fly, it's a bit difficult to narrow down. Can anyone give me an idea as to what is causing this and how I can retain the alignment? Each Node moves in the following way:
translateTransition.setFromX(node.getLayoutX());
translateTransition.setToX(node.getLayoutX()-500.00);
If I've left out any pertinent information, please let me know!
So, my issue turned out to be the way I'm laying out my objects. Placing them in an arbitrary AnchorPane with only specific attributes to locate those items means that, upon animation, it will group those objects and animate them accordingly. It was the incorrect way to layout those nodes.
Instead, I've placed them in a VBox which has two advantages.
I can align the contents of that VBox centre, so I need not specify the exact layout attributes of the elements.
I can animate using the single VBox, as opposed to the all the elements in a ParallelTransition. As a result, a single TranslateTransition on the VBox node will suffice!

IBM Rational Functional Tester Java

I am new to RFT and Java coding and I was trying to automate a web based application using IBM-RFT tool with Java. I have to click on a link within my HTML table cell. While playback it was able to click on links for some cells but for some it wasn't and was clicking above or below the hyperlink in the cell. It is able to recognize the link object and print out its properties like ".text", ".href" but while clicking it clicks on blank space within the cell instead of clicking on the link and this happens for some cells only.:(
Is there any better way to handle this? Appreciate anyone's help on this.
TestObject[] tablename = root.find(atDescendant(".class", "Html.TABLE", ".id", table_name), true);
GuiTestObject tablename_obj=(GuiTestObject)tablename[0];
TestObject cellObj = tablename_obj.find(atList(atChild(".class" , "Html.TBODY"),atChild(".class" , "Html.TR",".rowIndex", row),atChild(".class" , "Html.TD",".cellIndex",col)), false)[0];
TestObject cellObjClick = cellObj.find(atDescendant(".class","Html.A"))[0];
((GuiTestObject)cellObjClick).click();
Please help!
I can try to give you some clues. The .click() method calculates the center of the object as the click point. Since you can get the .href property and it is correct, then you know you have the link you want to click on. It could be that somthing about the extent of the object (the rectangle surrounding the object that is used to calculate points within the object) is somehow incorrect coming from the DOM. It could be that the click point calculated does not actually click on any part of the link in the UI. Instead of .click(), you could try using a speciic x, y coordinate for the link object. Note the coordinate is relative to the upper left corner of the object. So you could try .click(atPoint(x,y)), choosing some value (pixels) for the x, y coordinate and see if you have any better luck. You could also try getting the rectangle of the link (the extent) fist to see if that looks correct. I have sometimes used .click(atPoint(1,1)). I'm not sure you can see the rectangle of the object in it's properties, using the object explorer in RFT (you could try this).
I prefer using SelectGuiSubItem like the example below sometimes to click
((SelectGuiSubitemTestObject) textObj).select("<>");
Try that out instead of a click()

Superimposed node in javafx

Maybe the title of my question is not good but actually I don't know how to name it.
So I will try to explain my problem really clearly.
So I want to know if its possible to make like a "ErrorBar" inside my scene. I understand by this to show this element over other node inside the scene for a short time.
I have a BorderPane and I want when I have an error in my application (like webservice error) to show the error to the user. And for that I want to move a gridpane from the right to the left of the screen without change my scene (like put this object in the top of the borderpane).
I don't have any example with a software who do it but I think some stuff in Javascript can do something like this. Just show a green or red bar in the top of the website event it's somthing already show.
If someone know how to do that it will be great.
Actually I use Java 8 latest version.
Feel free to ask more if you want to know more about my question.
Thanks in advance.
Fische
I think you can just use a StackPane which allows you to work with "layers". Indeed in the StackPane, each Node you add to it becomes a "layer" and appears above previously added Nodes. Meaning that the latest Node will always be on top.
Knowing that, you can add your error message to the StackPane and then, if you use a transition to move it, at the end of the transition you automatically remove the message from the StackPane.
Hope it helps.

Placing Objects in a certain layout(For game)

So this what i want to do, i have a scene right now, and i want to create "Pages" on the scene with level icons i create.
Now i want to be able to set the amount of levels i want to have. for example,
int levels = 100;
Then i want it to be able to create "Pages". What i mean by pages is it will be space between each of the level sections.
I would like to be able to set the rows and columns like this:
int rowsPerPage = 5;
int colPerPage = 10;
Each of my level icons are 80x80 width and height.
So with this information i would like be able to place the level icons on rows per page bases and column per page basis.
Each level icon should have some padding space between them.
Once it reaches its makes row and column per page on the first page i would like to create a second page making some space between the first set of rows and columns. Once it reaches is max icon per row it should then start a new row on that page
Right now im not sure where to begin. The reason i am using this is because i have set up gesture detection so my users can scroll from "Page" to "Page" to select a level.
I know this isnt a place to just ask for code, but im stuck on my current project because of this and it would be really great to get some assistance.
Thank you guys in advance.
Thank you.
No one will write your code for you if you haven't even attempted it yourself...
This is from google... It may not be exactly what you want. However, it is a start :)
http://www.andengine.org/forums/tutorials/menu-scroll-example-t5740.html

Formatting JEditorPane's cursor, tooltips, links

Right now, I'm using Java Swing to create a JEditorPane primarily for its ability to have hyperlinks. I've successfully been able to display links and have them execute behavior upon a click, but I'm running into a few problems with formatting.
How can I set the cursor so that it normally is an arrow, but changes to a text cursor when hovering over text? (In essence, the behavior a cursor has within a web browser). I tried
EditorPane.setCursor(new Cursor(Cursor.TEXT_CURSOR))
but that made it a text cursor everywhere, even when not hovering over text. Right now, hovering over a link shows a pointer hand; I'd like to maintain that functionality as well.
What is the best way to show tooltips or mouseover text when hovering over a link? I tried modifying the title attribute of the link but nothing showed up.
I was trying to implement links to skip down to a subsection of the page, much like http://en.wikipedia.org/wiki/Xkcd#History would take you directly to the History subsection of Wikipedia's xkcd page. How can I do this?
An answer to any of these would be great (and multiple would be awesome xP). Thanks a lot for your help!
As you said one can simply give answers to a single point as well, let me try one by one, here is the answer for your last Point 3
Just provide an id to your tag like this
<h1><a id = "top"></a>First Line</h1>
Now somewhere in the bottom of your page write this :
<p>Return to TOP</p>
Clicking this link, you will reach the above area of the PAGE.
Points 1 & 2 may be addressed using the approach mentioned here. In particular, the view/model conversion methods will let you condition setCursor() and getToolTipText(), respectively.
You can get source from here http://java-sl.com/JEditorPaneStructureTool.html
It shows how to obtain text view bounds. First you get caret position for current mouse poiunter using viewToModel() method. Then go down the Views tree achieving leaf view and calcualte it's bounds. See this http://java-sl.com/tip_view_rectangle.html
If your mouse pointer in the view's rectangle then your mouse over text.
You can check whether the text in caret position is link and show your tooltip.
Use this http://java-sl.com/tip_links_in_editable.html to see how to detect whether mouse is over link.
Point 3.rd is answered by #nIcE cOw

Categories

Resources