Dragging of Jtable cell data on to other object
I am struggling a lot to use the coordinates with Drag method. The desktop application does not support copy/paste action on the object and we have to drag the data on it.
I have attached an image. So, we have two objects in image, On top right, the object 1 jtable has few rows and we need to drag data from row 1...5 and col 1. (mean all cells in the first col). The height of each cell is 20 i.e each jtable cell is 20 + 20 + 20 and so on.
Now the problem is I am unable to quite understand the parameters in the drag method. Four parameters are required, the first two seems to be working, but last two creating problems in combination with the first two parameters.
I'm looking for a solution based on some equation using ScreenLeft and ScreenTop of both objects.
Can anyone help by suggesting an equation by looking at the attached image please. This is something I need to proceed with my next scenarios.
I'm using scripts and BDD scenarios.
Thanks in advance.
Solved! Go to Solution.
No I don't see the text. Unfortunately the table cells are not editable and neither we can paste data in them. So the AWTComponentAccessibleName is empty.
But, for some other objects (where we want to drag something), the AWTComponentAccessibleName stores its title/label.
It doesn't have to be editable. Just looking for any object property that has the text you want. Post a screenshot of the Extended object spy please and let's take a look.
So as in attached image, there's just one Extended property for the Jtable that contains the text.
However, I have an idea but don't know how to quickly implement this and if it will affect any thing in java application code.
So the idea is to extract the text of the table cell by using any getText method available. And once the text is stored in a variable, use that variable to set the text to the object in which we want to attach that text. But, the problem is if its possible to change or update the text of the java object and if that's something which won't cause any issues in the functionality.
Okay, so now you have the needed text in a variable, good!
As far as changing the value of the second object, that was going to happen with drag and drop too. You may be able to use Keys on the field where the data goes rather than SetText. If neither one of those works, then explore this second window with ObjectSpy and lets see where the data is going to be entered.
Thank you for your help so far.
I will try the methods we discussed. Meanwhile, can you please help me understand the difference between the parameters of the Drag action. TestObj.Drag(ClientX, ClientY, toX, toY, Shift), I cannot really understand how ClientX is different from toX and same for Y parameters. If you could use the image I attached as an reference, that would make it much easier for me to understand.
Thanks very much!
Client X and Client Y are the position where your original value is. It clicks there, then drags the object to the new position toX and toY.