Unable to click on run time generated game object

30 views
Skip to first unread message

jagori

unread,
Sep 22, 2022, 11:14:26 AM9/22/22
to AltUnity - UI test automation tool for Unity3D
Hi,
I am new to AltUnity tester.I am trying to click on a game object which is loaded at runtime  and is a sprite but my script wont tap on it.I have tried all 3 Click(), Tap(),PointerDownFromObject().
But it's still not working.
My script is as below:
[Test]
    public void Test()
    {
        //Here you can write the test
        altUnityDriver.LoadScene("Login");
        altUnityDriver.FindObject(By.NAME, "Login").Click();
        altUnityDriver.WaitForCurrentSceneToBe("Navigation");
        altUnityDriver.FindObject(By.NAME, "Closed Book").Tap();
        Thread.Sleep(1000);
            
    }
Any help why am unable to click on this object
book.png

Alexandru Rotaru

unread,
Sep 23, 2022, 3:23:47 AM9/23/22
to jagori, AltUnity - UI test automation tool for Unity3D
Hello,

I assume that you can find the object using By.Name, no error message is thrown, but you don't see any action taken when you call Click() or Tap() on the found object. Did I get this right?

Unfortunately the screenshot from the Unity Editor is not enough for us to understand your object's properties (classes). I assume you also have a Button class there, that should be clickable (I don't think the Sprite Render is clickable). 
Can you try to take a screenshot with all the properties? The easiest way would be to use the AltUnity Inspector to see your object hierarchy, but you should also find the needed info with the Unity Editor.

Also, I think it's faster to get answers to your question through our discord server.

Thanks,
Alex

--
You received this message because you are subscribed to the Google Groups "AltUnity - UI test automation tool for Unity3D" group.
To unsubscribe from this group and stop receiving emails from it, send an email to altunityforu...@altom.com.
To view this discussion on the web visit https://groups.google.com/a/altom.com/d/msgid/altunityforum/6832cd73-c18c-4044-8084-8eb5ad06763fn%40altom.com.


--
--------------------------

Alexandru Rotaru

jagori

unread,
Oct 4, 2022, 8:26:25 AM10/4/22
to Alexandru Rotaru, AltUnity - UI test automation tool for Unity3D
Hello Alexandru,
Thankyou for your prompt reply.I again retried a couple of different methods but still couldn't make it work.I know I am approaching it the wrong way.
I apologise for answering so late.I tried getting in touch with the developer to get more clarity as to what is happening in the code.
So, to answer your question,yes I was able to find the object by name and no error was thrown.
There is no button so this is probably why the tap() and click() is not working.
So this object is a sprite and has an InteractableObject.cs component attached to it with a function inside OnPointerDown() which gets called when the user clicks on the boxcollider attached to this object.Let me share the entire property that shows in the Inspector as well as the script.

Please note I have attached the Inspector window screenshot in 3 parts as it was too big.
I am also attaching the InteractableObject script.

Looking forward to a reply soon.
I will join discord too.
Thanks and regards,
Jagori

InteractableObject script.txt
Ins_1.png
Ins_2.png
Ins_3.png

Alexandru Rotaru

unread,
Oct 7, 2022, 4:51:15 AM10/7/22
to jagori, AltUnity - UI test automation tool for Unity3D
Hi Jagori,

We looked over your issue and at this point we don't understand why it's not working... The only reason we think of is if the FindObject is returning a different object with the same name.. 

So I have two suggestions to further debug this issue:
  1. install the AltUnity Inspector - you can start a free trial form here - and try to click on that button from the inspector. You will need the game instrumented with AltUnity Tester for that.
  2. add some log messages in your script inside the OnPointerDown() and OnPointerUp() methods. This will tell us if those particular methods are called when you Tap() or Click().
I hope this will bring more light to this issue!

Alex
--
--------------------------

Alexandru Rotaru
Reply all
Reply to author
Forward
0 new messages