Coder Social home page Coder Social logo

gwaredd / unium Goto Github PK

View Code? Open in Web Editor NEW
228.0 19.0 44.0 17.07 MB

Automation for Unity games

License: MIT License

C# 58.81% HTML 4.20% CoffeeScript 9.28% JavaScript 4.23% CSS 23.49%
unity automation testing test-automation selenium appium unity3d

unium's People

Contributors

dependabot[bot] avatar gennrichj avatar gwaredd avatar gwaredd-rovio avatar kbssj1 avatar lacostej avatar partlyhuman avatar preloaded-tech avatar theeyeofbrows avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unium's Issues

Unity 2018.2+ deprecates Networking API

Updating Unium for Unity 2018 might require some refactoring. Ignoring errors in sample code, compile errors stem from the UnityEngine.Network API being deprecated.

e.g. Assets/Unium/UniumComponent.cs(118,65): error CS0619: `UnityEngine.Network.player' is obsolete: `The legacy networking system has been removed in Unity 2018.2. Use Unity Multiplayer and NetworkIdentity instead.'

image

.NET framework support

I am planning to use this for test automation for devices and wanted to know if it works with .NET framework subset 2.0.

Maintenance of unium "API"

This is not an issue in the code per se, but a question on good practice.

How do you manage the maintenance of the scripts that interact with your code through unium?

E.g. do you document that some code is made public in order to be accessible by Unium?

Null exception(s) while serializing GameObjects and Transforms

In my project, during a GQL query, objects being serialized can have child components/transforms can have null values.

This causes null exceptions in UnitySerialisers.cs (during the foreach loops).

It would be nice if the serializer could skip the null components and continue serializing.

Make Unium class public?

I am trying to add custom handlers without modifying Unium itself. Shouldn't the Unium class be public?

Or maybe have a way to expose the Unium.RoutesHTTP instance in some way?

GQL cannot find DontDestroyOnLoad objects

Because the /scene endpoint evaluates all root objects on all loaded scenes, it actually fails to catch objects that have set DontDestroyOnLoad in its net. These objects in a sense don't live in a scene. I am trying to think of a more elegant solution for this than iterating through FindObjectsOfTypeAll<Transform>(), mapping to the root of the transform hierarchy, and taking only unique entries, but at the moment coming short. If there's a way to do this more efficiently that'd be ideal. Of course this might also be another reason to consider more specific endpoints in addition to /scene/, so that you can have the old and efficient behaviour with /scene/ and more power/less efficiency when you need it.

How to use UniumSimulate click for object with different anchor

I'm trying to click a certain object on screen but when I get the RectTransform.position they are in negative number. Then of course the /q/simulate.click function doesn't work properly.

Upon closer inspection it seems all the objects have different alignments/anchor etc.

For some buttons I can use the Button.onClick.invoke() but others I wasn't able to. Is there a way to get correct position on screen so that I can use /q/simulate.click function?

Websockets in Unity 2019 and 2020

I'm running the tutorial, and the RESTful interface works fine, but the steps that use websockets fail with the message

Error connecting to game - is it running?
Connection closed

Debugging the JS, I see

Firefox can’t establish a connection to the server at ws://localhost:8342/ws. tutorial.js:34:48624

This isn't surprising, since UNet is deprecated and Unity is changing their networking libraries. Is there a Websockets library that needs to be installed or enabled for this to work with newer versions of Unity?

And finally, this package is really cool. Thanks for creating and sharing it.

[FeatureRequest] Get the scene hierarchy tree json

I would like to make a interactive treeview ui for unity gameobject hierarchy on web browser. However, most of the javascript treeview ui supports hierarchy tree json instead of the flat json that returned by Unium GQL.
The following is hierarchy tree json example.
e.g. [ { "name": "Parent", "children": [ { "name": "Child1", "children": [] }, { "name": "Child2", "children": [ { "name": "Child2_1", "children": [] } ] } ] } ]

websocket not work in il2cpp

I tested on unity5.6.x with il2cpp android build
when connect using websocket, it close the connection immediately.

12-16 12:12:17.267: I/Unity(1037): Listening on 172.16.247.102:8342
12-16 12:12:17.267: I/Unity(1037):
12-16 12:12:17.267: I/Unity(1037): (Filename: ./artifacts/generated/Android/runtime/DebugBindings.gen.cpp Line: 51)
12-16 12:12:17.267: I/Unity(1037): [unium][0] server listening on 172.16.247.102:8342
12-16 12:12:17.267: I/Unity(1037):
12-16 12:12:17.267: I/Unity(1037): (Filename: ./artifacts/generated/Android/runtime/DebugBindings.gen.cpp Line: 51)
12-16 12:12:17.297: D/Unity(1037): Sensor : Accelerometer ( 1) ; 0.009577 / 0.01s ; BMC150 Acceleration Sensor / Bosch Sensortec
12-16 12:12:17.317: D/Unity(1037): Choreographer available: Enabling VSYNC timing
12-16 12:12:17.337: D/Unity(1037): Setting up 1 worker threads for Enlighten.
12-16 12:12:17.337: D/Unity(1037): Thread -> id: ffffffffb841f3f8 -> priority: 1
12-16 12:12:17.337: D/Unity(1037): ANativeWindow: (720/1280) RequestedResolution: (0/0) EGLSurface: (720/1280)
12-16 12:12:23.747: I/Unity(1037): [0] OPEN /ws - 172.16.252.127:37437
12-16 12:12:23.747: I/Unity(1037):
12-16 12:12:23.747: I/Unity(1037): (Filename: ./artifacts/generated/Android/runtime/DebugBindings.gen.cpp Line: 51)
12-16 12:12:23.757: I/Unity(1037): [unium][1] [sock:0] connected - /ws
12-16 12:12:23.757: I/Unity(1037):
12-16 12:12:23.757: I/Unity(1037): (Filename: ./artifacts/generated/Android/runtime/DebugBindings.gen.cpp Line: 51)
12-16 12:12:23.767: I/Unity(1037): [ws:0] Opening websocket id:0
12-16 12:12:23.767: I/Unity(1037):
12-16 12:12:23.767: I/Unity(1037): (Filename: ./artifacts/generated/Android/runtime/DebugBindings.gen.cpp Line: 51)
12-16 12:12:24.787: E/Unity(1037): [ws:0] Fatal error - at System.Net.Sockets.NetworkStream.EndRead (IAsyncResult ar) [0x00000] in :0
12-16 12:12:24.787: E/Unity(1037): at gw.proto.http.WebSocket.OnRead (IAsyncResult asyncResult) [0x00000] in :0
12-16 12:12:24.787: E/Unity(1037): at System.Net.Sockets.Socket+SocketAsyncResult.Complete () [0x00000] in :0
12-16 12:12:24.787: E/Unity(1037):
12-16 12:12:24.787: E/Unity(1037): (Filename: ./artifacts/generated/Android/runtime/DebugBindings.gen.cpp Line: 51)
12-16 12:12:24.787: E/Unity(1037): [ws:0] Terminating connection - System.IO.IOException: EndRead failure ---> System.Net.Sockets.SocketException: Operation on non-blocking socket would block
12-16 12:12:24.787: E/Unity(1037): at System.Net.Sockets.Socket+SocketAsyncResult.CheckIfThrowDelayedException () [0x00000] in :0
12-16 12:12:24.787: E/Unity(1037): at System.Net.Sockets.Socket.EndReceive (IAsyncResult asyncResult, SocketError& errorCode) [0x00000] in :0
12-16 12:12:24.787: E/Unity(1037): at System.Net.Sockets.NetworkStream.EndRead (IAsyncResult ar) [0x00000] in :0
12-16 12:12:24.787: E/Unity(1037): at gw.proto.http.WebSocket.OnRead (IAsyncResult asyncResult) [0x00000] in :0
12-16 12:12:24.787: E/Unity(1037): at System.Net.Sockets.Socket+SocketAsyncResult.Complete () [0x00000] in :0
12-16 12:12:24.787: E/Unity(1037): --- End of inner exception stack trace ---
12-16 12:12:24.787: E/Unity(1037): at System.Net.Sockets.NetworkStream.EndRead (IAsyncResult ar) [0x00000] in :0
12-16 12:12:24.787: E/Unity(1037): at gw.proto.http.WebSocket.OnRead (IAsyncResult asyncResult) [0x00000] in :0
12-16 12:12:24.787: E/Unity(1037): at System.Net.Sockets.Socket+SocketAsyncResult.Complete () [0x00000] in <filename unk
12-16 12:12:24.787: I/Unity(1037): [ws:0] Connection closed
12-16 12:12:24.787: I/Unity(1037):
12-16 12:12:24.787: I/Unity(1037): (Filename: ./artifacts/generated/Android/runtime/DebugBindings.gen.cpp Line: 51)
12-16 12:12:24.787: I/Unity(1037): [unium][2] [sock:0] closed

How to automate an application on android device using this framework ?

I have downloaded the framework and added it to my application, able to interact with the application from browser using GQL, by following all the steps as you have mentioned in the README file.

But when I build an apk file and install it on android device, How do I interact with the application installed on device using GQL.

And I am able to launch that application installed on device through Appium. But I don't know how to interact with that launched application using this framework.

I am new to this unity and unium framework, please help me with this. Thanks in advance

Cannot detect the element in IOS

I am trying to perform some click operations on a ios build. The same code works fine with Andriod but not with iOS. Does unium support ios?
I have used unium as a bridge between appium and app. I have also setup xcuitest driver.
I am able to install and launch the application but cannot perform operations in app.
I am trying to inspect the element the element using phone ip
Ex: 10.0.0.59:13000/q/scene/canvas/button
Browser cannot detect the element.

HandlerUtils.cs failed to compile under Unity 2018.3.4f1

Hello,
I may be wrong but I could not compile Unium under Unity 2018.3.4f1.
I have an an issue with ScreenCapture.CaptureScreenshot( filename ); l 136 in HandlerUtils.cs.
I have looked in the history of the file and also looked for a custom implementation of ScreenCapture class, but found nothing.
So I think you are using the ScreenCapture class from Unity. Now it seems located inside UnityEngine. I had the code compile by changing :
ScreenCapture.CaptureScreenshot(filename); to
UnityEngine.ScreenCapture.CaptureScreenshot(filename);

Regards,
Jerome.

Running unium at AWS Device Farm

Hi. Thanks for fantastic framework. One of my big wishes will be to run this on public device farms such as AWS Device Farm. Do you have any ideas how to approach implementation of this feature. As a programmer I can certainly contribute to code this feature. My first idea is that we can implement special appium driver to forward our messages via appium server.

Is it possible to integrate with e.g. Katalon test framework?

It is mentioned in the Unity Asset store: "It embeds a web server into debug builds of your project which provides an interface and a query language the enables you to remotely control your game. This means you can use your favourite testing frameworks to write automated tests."

Does it mean that you could integrate with e.g. Katalon?

Unable to retrieve specific element instance with square brackets for objects with duplicate names/content

Hey there, thanks for the great framework here! I'm having trouble trying to access a specific instance of an element in a browser when multiples appear on a page (with identical properties). Page 6 of the help document seems to indicate that square brackets can be used to filter a specific instance of a element (exact reference below), but adding the square brackets does not seem to filter out that instance. I've tried putting the brackets in various locations, but can't seem to isolate the instance.

How can I access a specific instance of an element? Or in the attached example here, what would I have to modify in that URL to get a single ["Indicator"] to appear on the page? Thanks for any help on this!

unium

Find all the pickups and return the 3rd one from the list (0 based index naturally)
/q/scene/Game/Pickup[2]

Running Unium on Android

I've been trying to run the Unium Tutorial on my Android device but without success. I noticed that you had some Android-specific code in there so was wondering if you have any advice on troubleshooting the issue.

Here's my setup:

  1. Both Mac & Android device are on the same Wifi network
  2. Unium Tutorial running on Android
  3. Run the following command from my Mac:
$curl http://10.9.105.223:8080/about
curl: (7) Failed to connect to 10.9.105.223 port 8080: Connection refused

I tried a couple things:

  1. UniumComponent.StartServer() overrides the Settings.Address for non-editor apps. I changed it to always force the Address to IPAddress.Any.
  2. Tried several other ports. I'm always able to hit a server running on my Mac from the phone, but not the other way around.

(PS: Thanks for this awesome tool, it's exactly what we've been looking for! We think it's going to change how we approach testing. Planning on leaving a review on the asset store once we get this up and running!)

Thanks,
Saswat

assert whether the operation was successful

How to deny whether the interface switches after clicking the button, whether some UI elements are switched, hidden, modified attribute values, whether the object is destroyed, and whether the scene is loaded. Output test report (assertion) to text

can it work on webGL platform?

I packaged the unity project, it was a webGL,with ​Development Build​ is
true then I opened the project on the webpage, and the unium homepage did not open.
And,on the PC platform,the unium homepage opened,but can't find the web,the web was wrong.
image
20190418175718

Unity package import doesn't work due to missing meta-file

Hi,

I really like the Unium framework of yours for UI testing and I wanna include it in my university projects. Now, I tried to import Unium via the package.json, which you added a couple of days ago. Works nearly okay, but you are missing a package.json.meta in your Packages-folder. So, when I import the Unium package, I get an error in Unity saying:

Read only asset Packages/com.gwaredd.unium/package.json has no meta file.
System.Reflection.MethodBase:Invoke(Object, Object[])
JetBrains.Rider.Unity.Editor.UnityUtils:SyncSolution()
JetBrains.Rider.Unity.Editor.PluginEntryPoint:SyncSolutionOnceCallBack()
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()

Could you fix that for some later commits ? It's not super-urgent, but I'd really like to import your work in my projects and that needs to use the package method because of the CI pipeline.

Thanks a lot, Great work you did,

Christian

Not all scenes are listed when calling the `utils/scene` endpoint

Hi there,

First of all I want to say thank you for putting together this library. It is pretty well thought out and, for an initial, "experimental" version, it has been surprisingly stable!

I am in the process of writing a Javascript client wrapper for the HTTP API and ran into what appears to be either a documentation issue or a bug. When making a GET request to utils/scene/oijsfiojeoijioejfjoi while running the tutorial scene, I get the following response:

{"loading":"ojieiofjeoijfe"}

Indeed, when looking at the logs, I see the following:

image

However, the PDF states that the endpoint should "Load a scene by name (e.g. /utils/scene/tutorial). If no name given then list all scenes."

Rather than fixing it directly, I think it would be great if the functionality was split into multiple endpoints, following a more RESTful model:

  • GET utils/scenes - lists the available scenes in a JSON array
  • GET utils/scenes/<name> loads metadata about a scene. Returns a 404 if the scene does not exist
  • POST utils/scenes/<name> loads the scene by name. Returns a 400 (bad request) if the scene is not available to load.

Doing this split would separate functionality into explicit read/write calls and simplify the design of a client library. By leveraging HTTP semantics, it also would make the API more familiar to those with a web development background.

How does this sound to you? Do you have other ideas on how you'd like to see this work? I am happy to consume it whatever you decide. Thanks again!

the format of scene hierarchy tree json show on the webpage is wrong

The scene hierarchy tree has been obtained, but the format displayed on the web page is incorrect.
the format show on the webpage likes this:
"[{"name":"Sphere","tag":"Untagged","activeInHierarchy":true,"components":["Transform","MeshFilter","MeshRenderer","SphereCollider"],"children":["Cube","children":[],"Cube (1)","children":["Sphere (2)","children":["Cube","children":[],"Cube (1)","children":[]]]]}]"
image
image

Running unium for a built project

Hi,

Sorry if my question may sound silly or naive, I am a total novice in Unity.
I am able to interact with the app through http://localhost:8342 when I run it from Unity editor. However, if build the app and run the .exe file instead, I cannot access the unium web server.
Is there a way to enable the web server in the built apps?

/Sergey

iOS - Unable to bind

I have been playing around to validate this tool. So far everything is working as intended. I have come across an issue trying to run a couple of tests on an iOS device. When I attempt to bind to events.debug it returns with 'Not Found'.

I have narrowed the line of code when an exception is being thrown to EventListener line 40 eventInfo.AddEventHandler( Target, Delegate );.
The exception message is 'A null value was found where an object instance was required.'

The exact same code and bind call works in the Editor and on an Android device.

How can I invoke an Event Trigger function?

Hi there @gwaredd ,

Im evaluating Unium and I have run into an issue.

I am able to click on game objects that have the Button component with gameObject.Button.onClick()

However, for game objects that ALSO have an EventTrigger, I am having some trouble. If I do gameObject.Button.onClick() on a gameObject that also has an event trigger component. the click does not actually happen.

I am unsure how I can instead invoke the function in an Event Trigger?

if I do gameObject.EventTrigger I get an appropriate response.

Ive tried things like gameObject.EventTrigger.onPointerDown() but that isnt correct

Please see the screenshot of the game object properties, would really appreciate help on how to successfully click this gameObject -> https://imgur.com/a/XC9WuR6

Thanks!

Obtaining an image or its filename

The thing I try to do: doing an automation based on a certain requirement which in the game shown as an image.

Is it possible in Unium to get the sprite/image or its filename on an Image component using Unium?

Outside Editor, Unium web server binds to a single interface only

This appears to be by design but the behaviour is not desired in my application. In the editor the Server uses IPAddress.Any, which lets me connect to the Unium instance on

  • localhost
  • 127.0.0.1
  • any loopback address (127.0.0.*)
  • hostname
  • its public IP

However due to line 117 of UniumComponent.cs, in a build, I can only connect to the unium instance at the IP detected by Util::GetIPAddress(). Besides being hard to always look up the external IP, this creates problems when there are multiple network interfaces (for instance ethernet + wifi) and we need to use ethernet on the local subnet but it grabs the IP from the wifi connection instead.

I can fix this by commenting this out and leaving IPAddress.Any, but I think it might be better to leave it that way by default, or expose the choice as an option.

how to use take screenshot

i create an empty object(named GameObject) ,with third person camera script,target is GameObject,but it has a wrong when run the scene.
image

Cloned object paths cannot be resolved

If you have a cloned GameObject with the name like "MyGO(Clone)" then when trying to just reference that by its path I get an error:

GQL::Query - failed to parse query, no attribute to set

Looking at the regex code it looks like it's taking the () brackets as an indication that it's an action (method invoke?) query when all I'm actually trying to do is get that GO's info.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.