Finding a dynamic element

1 view
Skip to first unread message

Christopher Williams

unread,
Jun 16, 2020, 3:43:37 PM6/16/20
to AltUnity - UI test automation tool for Unity3D

Hi. I am attempting to select a dynamic element, the element name PF_GameTile(Clone) is not unique, with other elements sharing the same name. (see screenshot top left). The only difference seems to be the game reference name within the Game Tile component. (bottom right) How can I find this object? 
 Thank You 
Screen Shot 2020-06-16 at 3.23.51 PM.png

Robert Poienar

unread,
Jun 17, 2020, 2:34:53 AM6/17/20
to AltUnity - UI test automation tool for Unity3D, chwi...@gmail.com
Hi, we don't have a specific command to do this so it will no be straightforward. What you can do is the following:
  1.  use FindObjects() to get all PF_GameTile(Clone) 
  2.  with a for go though every object and check with GetComponentProperty to get the game it references.
If you get the right game then you got the object you are looking for.

Christopher Williams

unread,
Jun 17, 2020, 9:38:28 AM6/17/20
to AltUnity - UI test automation tool for Unity3D, chwi...@gmail.com
Thank You so much. I am trying to figure out GetComponentProperty. I am not sure I am doing this right and the test is still failing. Also I am trying to click the particular component. Can you please explain what I am doing wrong and how to go about clicking the particular component I need. See attachment for my current code. Thank You 
Screen Shot 2020-06-17 at 9.34.56 AM.png

Robert Poienar

unread,
Jun 17, 2020, 9:58:40 AM6/17/20
to altuni...@altom.com, chwi...@gmail.com
The component and the property are wrong. Component name should be the name of the class name: GameTile from what I see from screenshot, and the property name: game or Game. 
To find your object you do something like this inside the for:

if("Wingspan Game".Equals(altElement.GetComponentProperty(componentName,propertyName))
 searchedObject
=altElement;// Or whatever operation you want to do with it


If you want to click the object you can do the following: searchedObject.Tap()

Christopher Williams

unread,
Jun 17, 2020, 10:25:18 AM6/17/20
to AltUnity - UI test automation tool for Unity3D, chwi...@gmail.com
Thank You rober for your quick response. I am new to altunitytester and c#. I have one more screenshot of the updates. I still am getting failures. I think it maybe in the if statement. Am I supposed to do altElement.Tap(); 
 Thanks again in advance.
Screen Shot 2020-06-17 at 10.22.41 AM.png

Robert Poienar

unread,
Jun 17, 2020, 10:43:05 AM6/17/20
to AltUnity - UI test automation tool for Unity3D, chwi...@gmail.com
You probably getting ComponentNotFound. I don't think you should have spaces. You better check the script class name because UnityEditor shows in a more user friendly way. It is important to put the name of the class how it is declared so it should be "GameTile". Let me know if this still doesn't work. Also please add what error message you get.
Message has been deleted

Christopher Williams

unread,
Jun 17, 2020, 1:39:06 PM6/17/20
to AltUnity - UI test automation tool for Unity3D, chwi...@gmail.com
Everything is working now. Thank You 
Reply all
Reply to author
Forward
0 new messages