cancel
Showing results for 
Search instead for 
Did you mean: 

Object cannot be recognized again once it has been clicked

SOLVED
anapao
Occasional Contributor

Object cannot be recognized again once it has been clicked

Hi everybody,

 

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:

ImageRepository.AssetLibraryMenus.Menu_ExternalEnergyNetworks.Click()

MySourceObject = ImageRepository.Assets.ElectricGridConnection
ImageRepository.Assets.ElectricGridConnection.Click()
SX = Sys.Desktop.MouseX
SY = Sys.Desktop.MouseY

MyDestinationObject = Aliases.ComponentTreeView.qt_scrollarea_viewport
MyDestinationObject.Click()
DX = Sys.Desktop.MouseX
DY = Sys.Desktop.MouseY

 

MySourceObject.Drag(SX,SY,DX, DY)


Best, 
Paola

1 ACCEPTED SOLUTION

Accepted Solutions
AlexKaras
Community Hero

Re: Object cannot be recognized again once it has been clicked

Hi Paola,

 

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.

 

Regards,
  /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.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

2 REPLIES 2
sonya_m
Community Manager

Re: Object cannot be recognized again once it has been clicked

Thank you for posting your question @anapao ! Let's see if anybody faced similar issues/knows how to resolve this!

 

@Wamboo @Reshail @AlexKaras @BenoitB could you take a look? Thank you!😊


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
AlexKaras
Community Hero

Re: Object cannot be recognized again once it has been clicked

Hi Paola,

 

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.

 

Regards,
  /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.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors