LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use the Variant Attribute Get Function

Solved!
Go to solution

Thank you very much.
I will try this one as well.

0 Kudos
Message 11 of 19
(1,385 Views)

I am glad you developed the topic.

 

I am trying to automate UI testing for an application I created in labVIEW.
So I need to control buttons, dials, text boxes and other controls, determine if the screen is displayed, etc.
However, I have heard that it is not possible to access the controls directly with the spy tool or other tools.
So I thought of creating a sub-VI that would interface with an external application.
(I didn't want to modify the application under test if possible...)

 

Attached is the sub-VI I am working on. (Sorry, it may be difficult to read since it is partly in Japanese.)
I am trying to use a text file as an interface in this VI.
First, register all the VI names to be controlled in the sub-VI, and then output a text file with a list of all the controller names in the target VI.
(At this time, only the cluster name is output because the internal configuration of the cluster could not be obtained. In fact, I would like to control each controller in the cluster individually).
The external application uses this list as a reference to specify the VI name and control name in the request text file, and the write value in the case of writing, and performs control.
In case of read, the values are output in a result text file.
I would also like to use this sub-VI in other labVIEW applications.

 

As you said, if there is an easier way to do UI testing, I would like to know about it.
Please share your knowledge with me.

 

Thank you in advance.

Download All
0 Kudos
Message 12 of 19
(1,380 Views)

Here is a screenshot of the block diagram.
Thank you.

registerAllControls.png

MakeControlList.png

writeValueToControl(trying).png

0 Kudos
Message 13 of 19
(1,377 Views)

Hi raphschru,

 

I tried the "OpenG Toolkit" and it achieved my goal.
Thank you so much.

0 Kudos
Message 14 of 19
(1,362 Views)

@yuma_ysd wrote:

As you said, if there is an easier way to do UI testing, I would like to know about it.
Please share your knowledge with me.


There's no easy way to do this so it covers all LV's idiosyncrasies. I'd settle for 60%-90%.

 

The way you've made it you could run into a few problems.

 

You'd need to get control references recursively. Some controls could live in tab controls, and AllControls[] returns only the tab control's reference. Some for clusters, although you sometimes might want the cluster ref, sometimes it's element's refs...

 

You can't value (signalling) latch Booleans.

 

Things get notoriously hard if you want to support VIs in subpanels. Esp. if those VIs (with the subpanel or in the subpanel) are clones.

 

Triggering menus isn't possible. I usually direct menu activation to a (hidden) string control and handle the events in that string. That way I can 'inject' menus by value (signalling) a menu.

0 Kudos
Message 15 of 19
(1,350 Views)

BWT.

 

These kind of coding problems really clean up by using a map as a LUT, instead of two arrays.

 

However, you would need to upgrade (to >LV19 IIRC).

 

Ironically, without a map data type (e.g. in LV13), you could use variant attributes that work as a map 😂:

wiebeCARYA_0-1663145689776.png

 

Message 16 of 19
(1,334 Views)

I understand that many problems remain.
I wonder there was something that could be done about the problem, especially with regard to the latch Booleans.
It works for the program I am testing now, so I will update it as problems arise in the future.

 

As for the string control, I felt that it is necessary to create the target program with automated testing in mind.

 

Thanks also for the advice about LUTs.
So this is where the variant attributes come in handy🤔
I will give it a try as soon as possible.

 

Thank you.

0 Kudos
Message 17 of 19
(1,294 Views)

@yuma_ysd wrote:

I wonder there was something that could be done about the problem, especially with regard to the latch Booleans.


Don't use them is the easy solution.

 

Most non-trivial GUIs will have an event structure, so simply set the button to switch when released, and reset the value in the event.

 

I've been in situations where I couldn't change the latch Booleans (as the program was tested and released). You can resort to simulating a mouse click through Windows (assuming you're on Windows) but that can be hard. You need to convert pane coordinates to panel coordinates to screen coordinates. For that you need VI references, and if you're using reentrant VIs in SubPanels you need the reference of the VI hosting the subpanel.

 

This is hard because 1) references to clones are not officially supported (e.g. you can't get a list of clones) and 2) you can't get a subpanel reference from a VI reference. 

 

See this discussion about 2): VI property subpanel ref - NI Community... It seems I'm the only one that has difficulties with this, though.

 


@yuma_ysd wrote:

Thanks also for the advice about LUTs.
So this is where the variant attributes come in handy🤔
I will give it a try as soon as possible.


It's not just handy, it's also faster.

 

A 1D array's search time is linear (O), maps\variant attributes use a binary tree, and search time is log(O).

 

In LV19, there's little use for variant attributes anymore. A map does the same, but a map is strong typed. That's a huge benefit. Receiving a variant (from e.g. a subVI) is less descriptive than getting the actual type of the map.

 

Also, Maps can have any data type as key. Variant attribute keys must be strings. You can flatten to string, but that won't help with performance.

0 Kudos
Message 18 of 19
(1,262 Views)

I see. If the target program can be changed, I will actively try to change it.

 

It seems I still need to learn more.
Thank you for your continued support in other topics.

Message 19 of 19
(1,234 Views)