Object cannot be recognized again once it has been clicked
I have an object that is not mapped automatically and therefore I have to work with it as an ImageRepositoryObject.
I want to drag the object. To extract the coordinates, I click on it.
Afterwards, when trying to drag it, the object is not recognized anymore. In the Script Test Log appears "unable to simulate the Drag action. No image was found".
I do know that the click action is being succesfull because I get the right coordinates.
Any idea what is happening and how I could fix it? I would be very thankful!
Here the code in case it helps:
MySourceObject = ImageRepository.Assets.ElectricGridConnection
SX = Sys.Desktop.MouseX
SY = Sys.Desktop.MouseY
MyDestinationObject = Aliases.ComponentTreeView.qt_scrollarea_viewport
DX = Sys.Desktop.MouseX
DY = Sys.Desktop.MouseY
Solved! Go to Solution.
> I do know that the click action is being succesfull because I get the right coordinates.
a) Is there any chance that object is regenerated after click? If it is, then this may explain the error message, because your code does not search for the object before dragging but uses stored reference to it. And if the object is regenerated this invalidates the stored reference.
You may try to replace .Click() call with the .HoverMouse() one. This should return same coordinates but should not cause any object regeneration (if any);
b) Your code for drag seems to be incorrect. It uses absolute screen coordinates (e.g. Sys.Desktop.MouseX) while, as per documentation, the .Drag() method uses object-relative coordinates for drag start and not the final point but distance to drag for end. See method's description and code sample for more details.
/Alex [Community Hero]
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.