Coder Social home page Coder Social logo

Comments (21)

gwaredd avatar gwaredd commented on July 28, 2024

If I understand, you are trying to test whether clicking a button was successful? I assume you are running your tests remotely using a testing framework (e.g. pytest, mocha, nunit, or whatever).

It would be helpful if you have a specific example of scene and test framework to help you with. Otherwise, generally ...

Call the button.invoke() and wait for the HTTP request to finished then ...

You can test to see if an object has been destroyed by querying the hierarchy for the presence of the object, e.g. /q/scene/Some/Object - if this returns [] then it wasn't found.

You can test to see if it is active with by looking at the activeInHierarchy field for example /q/scene/Some/Object.activeInHierarchy

Same with any attributes you expect to have changed.

For loading a scene, the easiest way if to wait for a given length of time then see what the current scene is (using something like /about or /q/scene/[0].scene.path);

The more advanced way is to use websockets and bind to the sceneLoaded event

{"id":"sceneLoaded","q":"/bind/events.sceneLoaded"}

Then you will get a message when a new scene is loaded.

HTH

from unium.

kongguliu avatar kongguliu commented on July 28, 2024

If I understand, you are trying to test whether clicking a button was successful? I assume you are running your tests remotely using a testing framework (e.g. pytest, mocha, nunit, or whatever).

It would be helpful if you have a specific example of scene and test framework to help you with. Otherwise, generally ...

Call the button.invoke() and wait for the HTTP request to finished then ...

You can test to see if an object has been destroyed by querying the hierarchy for the presence of the object, e.g. /q/scene/Some/Object - if this returns [] then it wasn't found.

You can test to see if it is active with by looking at the activeInHierarchy field for example /q/scene/Some/Object.activeInHierarchy

Same with any attributes you expect to have changed.

For loading a scene, the easiest way if to wait for a given length of time then see what the current scene is (using something like /about or /q/scene/[0].scene.path);

The more advanced way is to use websockets and bind to the sceneLoaded event

{"id":"sceneLoaded","q":"/bind/events.sceneLoaded"}

Then you will get a message when a new scene is loaded.

HTH

I want to output the query results, such as the UI tree, attribute values to txt, where should I add the code, the JavaScript? Or where?

from unium.

kongguliu avatar kongguliu commented on July 28, 2024

.invoke() a

How to input a text into an inputField, like thi,:http://localhost:8342/q/scene/Canvas/UIManager/win_login/input/Accout/InputField/text.Text='20180001',but this is not successful
image

from unium.

gwaredd avatar gwaredd commented on July 28, 2024

Try Text.Text.text

http://localhost:8342/q/scene/Canvas/UIManager/win_login/input/Accout/InputField/Text.Text.text='20180001

First Text is the game object
Second Text the component
Then text is the field

from unium.

kongguliu avatar kongguliu commented on July 28, 2024

Try Text.Text.text

http://localhost:8342/q/scene/Canvas/UIManager/win_login/input/Accout/InputField/Text.Text.text='20180001

First Text is the game object
Second Text the component
Then text is the field

this is not successful!

from unium.

gwaredd avatar gwaredd commented on July 28, 2024

I want to output the query results, such as the UI tree, attribute values to txt, where should I add the code, the JavaScript? Or where?

Javascript console.log() would seem appropriate, assuming this is for development (either in browser or from node.js).

from unium.

gwaredd avatar gwaredd commented on July 28, 2024

Try Text.Text.text
http://localhost:8342/q/scene/Canvas/UIManager/win_login/input/Accout/InputField/Text.Text.text='20180001

this is not successful!

If you run the unium tutorial scene, you should see an IP address in the top left. You can change the displayed text with the following query,

    http://localhost:8342/q/scene/UI/IPAddress.Text.text=hello

Check this works for you ...

from unium.

kongguliu avatar kongguliu commented on July 28, 2024

Try Text.Text.text
http://localhost:8342/q/scene/Canvas/UIManager/win_login/input/Accout/InputField/Text.Text.text='20180001

this is not successful!

If you run the unium tutorial scene, you should see an IP address in the top left. You can change the displayed text with the following query,

    http://localhost:8342/q/scene/UI/IPAddress.Text.text=hello

Check this works for you ...

Strange,it is not in the tutorial scene,the query http://localhost:8342/q/scene/Canvas/UIManager/win_login/Text.Text.text=hello,it is successful.
but the query
http://localhost:8342/q/scene/Canvas/UIManager/win_login/input/Account/InputField/Text.Text.text=hello,it is not successful.

1555492469(1)

from unium.

gwaredd avatar gwaredd commented on July 28, 2024

What is returned by the unsuccessful query?

from unium.

kongguliu avatar kongguliu commented on July 28, 2024

What is returned by the unsuccessful query?

image

from unium.

gwaredd avatar gwaredd commented on July 28, 2024

The empty array [] means no objects were matched by that query.

Easiest way to find what's failing is maybe to start with something that works and try adding bits until it fails, e.g. ...

http://localhost:8342/q/scene/Canvas/UIManager/win_login/input
http://localhost:8342/q/scene/Canvas/UIManager/win_login/input/Account
http://localhost:8342/q/scene/Canvas/UIManager/win_login/input/Account/InputField
http://localhost:8342/q/scene/Canvas/UIManager/win_login/input/Account/InputField/Text
http://localhost:8342/q/scene/Canvas/UIManager/win_login/input/Account/InputField/Text.Text
http://localhost:8342/q/scene/Canvas/UIManager/win_login/input/Account/InputField/Text.Text.text
http://localhost:8342/q/scene/Canvas/UIManager/win_login/input/Account/InputField/Text.Text.text=hello

from unium.

kongguliu avatar kongguliu commented on July 28, 2024

The empty array [] means no objects were matched by that query.

Easiest way to find what's failing is maybe to start with something that works and try adding bits until it fails, e.g. ...

http://localhost:8342/q/scene/Canvas/UIManager/win_login/input
http://localhost:8342/q/scene/Canvas/UIManager/win_login/input/Account
http://localhost:8342/q/scene/Canvas/UIManager/win_login/input/Account/InputField
http://localhost:8342/q/scene/Canvas/UIManager/win_login/input/Account/InputField/Text
http://localhost:8342/q/scene/Canvas/UIManager/win_login/inpu/Account/InputField/Text.Text
http://localhost:8342/q/scene/Canvas/UIManager/win_login/input/Account/InputField/Text.Text.text
http://localhost:8342/q/scene/Canvas/UIManager/win_login/input/Account/InputField/Text.Text.text=hello

Sorry,the unsuccessful query returned this
image

from unium.

gwaredd avatar gwaredd commented on July 28, 2024

So either the value it is trying to set it empty (which is unlikely), or the value can't be changed , in which case it is unity related.

You can put a breakpoint here to step through the code and see what's going on.

from unium.

kongguliu avatar kongguliu commented on July 28, 2024

So either the value it is trying to set it empty (which is unlikely), or the value can't be changed , in which case it is unity related.

Whether because the text is inside a inputField,not just a text.

from unium.

gwaredd avatar gwaredd commented on July 28, 2024

Possibly yes, can you change the value on the InputField instead?

http://localhost:8342/q/scene/Canvas/UIManager/win_login/input/Account/InputField.text=hello

or

http://localhost:8342/q/scene/Canvas/UIManager/win_login/input/Account/InputField.SetTextWithoutNotify(hello)

from unium.

kongguliu avatar kongguliu commented on July 28, 2024

Possibly yes, can you change the value on the InputField instead?

http://localhost:8342/q/scene/Canvas/UIManager/win_login/input/Account/InputField.text=hello

or

http://localhost:8342/q/scene/Canvas/UIManager/win_login/input/Account/InputField.SetTextWithoutNotify(hello)

both were unsccessful,reply empty array []

from unium.

gwaredd avatar gwaredd commented on July 28, 2024

Oops, I meant InputField.InputField :)

http://localhost:8342/q/scene/Canvas/UIManager/win_login/input/Account/InputField.InputField.text=hello

from unium.

kongguliu avatar kongguliu commented on July 28, 2024

http://localhost:8342/q/scene/Canvas/UIManager/win_login/input/Account/InputField.InputField.text=hello

successful ,thank you very much!

from unium.

kongguliu avatar kongguliu commented on July 28, 2024

I want to output the query results, such as the UI tree, attribute values to txt, where should I add the code, the JavaScript? Or where?

Javascript console.log() would seem appropriate, assuming this is for development (either in browser or from node.js).

I want to output the returned array to a text instead of displaying it on a webpage or JavaScript console. Where should I add the code to a specific location in tutorial.js

from unium.

kongguliu avatar kongguliu commented on July 28, 2024

If I understand, you are trying to test whether clicking a button was successful? I assume you are running your tests remotely using a testing framework (e.g. pytest, mocha, nunit, or whatever).

It would be helpful if you have a specific example of scene and test framework to help you with. Otherwise, generally ...

Call the button.invoke() and wait for the HTTP request to finished then ...

You can test to see if an object has been destroyed by querying the hierarchy for the presence of the object, e.g. /q/scene/Some/Object - if this returns [] then it wasn't found.

You can test to see if it is active with by looking at the activeInHierarchy field for example /q/scene/Some/Object.activeInHierarchy

Same with any attributes you expect to have changed.

For loading a scene, the easiest way if to wait for a given length of time then see what the current scene is (using something like /about or /q/scene/[0].scene.path);

The more advanced way is to use websockets and bind to the sceneLoaded event

{"id":"sceneLoaded","q":"/bind/events.sceneLoaded"}

Then you will get a message when a new scene is loaded.

HTH

I used http://localhost:8342/q/scene/about,it returned empty array[],used http://localhost:8342/q/scene/[0].scene.path,returned "Assets/Scenes/Game.unity".
And I don't know where to add or change the code with {"id":"sceneLoaded","q":"/bind/events.sceneLoaded"}
image

from unium.

gwaredd avatar gwaredd commented on July 28, 2024

The route for about is http://localhost:8342/about (not /q/scene - its not a query :)

If you have multiple scenes http://localhost:8342/q/scene/*.scene.path will return all of them although it may give you multiple results as it's returning the scenes of all the top level objects (or scene.name if you just want the name rather than the path).

Binding to events requires the websocket interface which I don't believe you're using.

from unium.

Related Issues (20)

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.