Assign value for UiElement

Hi experts,

I created a pipline “Main” with a sub pipline “OpenRAFM”, which will find an UiElement and return it as a UiElemnet variable calld “MainWindow”.

It works if I run full pipline, but if I want to run a unit test, I need to assign value to “MainWindow”.

I can retrieve value from “watch”.

but how can I assign it into a variable manually when I do the Test Activity. Pasting the text I retrieved seems does not work. Does anyone know how to assign UiElement manually?

Thank you in advanced!

Hi @Sung_Hong_Wei

May be you can use find element activity pass the selector to get the uielement as output . Please try it out and let us know if it works as expected

1 Like

Hi,

We might be able to create UiElement instance statically. However, as UiElement has several parameter which is related with the target application such as ProcessID etc, it will make no sense in practical.

In this case, it’s better to use driver xaml which include UseApplication activity etc, then call the test target xaml from the driver.

Regards,

Thanks, but I think that’s what I am doing now. I want to do unit test which means I don’t want to add another active to get the element. I want to use the one I got before.

so even I can watch there only two attributes in “Watch” like following

, there are some hidden attributes I don’t know to declare an instance to use?

Hi,

If you want to get information for UiElement including attributes, can you try to use Immediate panel as the following?

For example, It’s necessary to have same PID with the actual running application. Even if we assign some value as PID, PID of target application might be changed at next run, and it make no sense.

Regards,

Thanks, may I ask what do you mean “next run”? Is run for UiPath or run for the target window?
Since I just want to do unit test, if the answer is the later(according to Immediate I think so), it still makes sense for me.

But in practice, is it possible to assign a new UiElement with several attributes? or is it possible keep the instance in memory and read it again when next test?

Hello @Sung_Hong_Wei

What is the purpose of assigning the uielement? Is it mandatory to use the script to find the uielement?

If you can give more insights to your requirement, maybe we can do it with UiPath activities itself?

Sorry for the lack of explianation.

We want to create a robot to do series operations on an application.

Here is my plan of UiPath (Main.axml),

  1. Open the application (output the UiElement “MainWindow”)
  2. Do operation A on “MainWindow”
  3. Do operation B on “MainWindow”
  4. Do operation C on “MainWindow”
  5. Do operation D on “MainWindow”

So when I developing operation X, I’d like to do TestActivity for operation X.

Because I have opened the application at step1, I don’t want to close it and open it again to just get the UiElement instance. (The application require a long time to initialize)

The workaround is adding a FindElement before “Do operation X on “MainWindow”” to get the window of the opened application like Lak_Ui said. It works but I need to removed it after finishing test, so I want to find a smarter way to do the TestActivity.