Collecting names for each UI elements and adding them together for each excel row

Hello

My automation goes through number in each excel row and there it copies names for each UI element. Sometimes for 1 excel row there are 2 names sometimes 5 times etc. The problem is that I need all the names in 1 row. I’m using studioX and I don’t know how to add the names to eachother.

This is my example:

I know that later I will need to do:
image

But I don’t know how to store all these names and add them for each excel row.

@anon40731888

For eachs et you can append the names to one variable and then witte the cell

May I know how do you differentiate how many names go into one cell?

Cheers

its 1 name for each ui elements and sometimes there is 1 element and sometimes 5 elements etc

how do you append them to one variable? the next excel row I must have this variable clear because it will be different set of names

@anon40731888

I guess you have two for loop…

In the first llop before starting the seconf loop set a variable say str to string.Empty

Now in the second loop where you loop through actual elements to perform get text in that use the below and assume get text value is stored in variable str1

Str = str + " " + str1

After the inner loop use write cell with str

Cheers

Hi @anon40731888

1.For each row in Excel
→ For each UI element
→ Use Get attribute activity to get the aaname or visibletext and store output in str_name
→ assign: str_output = string.CONCAT(str_output,str_name," ")
2. Use write cell activity to write to excel (outside for each UI element)

Hi I get an error:
image

any ideas?

@anon40731888

My bad, Use concat method
string.Concat(str_output,str_name," ")

image

It does not work, only one name still show when there are 3. (the middle name shows) any ideas?

@anon40731888

can you show your code …remaining one how it looks

did you try above mentioned method?

cheers

Get Text stores the name

image

@anon40731888

Do you have a out loop already or no?

Because how do you differentiate that the items need to go into one cell and multiple

Cheers

It is for each row.

So first loop is for each row and second loop is for each UI element - in for each UI element I gather names that I need to join together and then write it to the current row (in for each row)

I don’t know what I do incorrectly ehjh

@anon40731888

Go you…

Now use the write cell activity in the outer for loop and not in the inner…so move it from
The current place to outside loop

So your flow will be like this

  1. First for loop
  2. Assign str_Output = string.Empty
  3. For loop on ui element
  4. Inside 3 get attribute
  5. Inside 3 assign with str_output = str_output + " " + Str_name
  6. Inside 1 and outside 3 …write cell activity with str_output

Hope this helps

Cheers

IT now says this. Any ideas?

@anon40731888

Str_output = is not needed on right…I gave both values that are to be present on each side of set variable…please remove it

The whole idea is to move write cell outside the inner loop and have it in the outer loop

And initialize the str_output before inner loop starts

Cheers

THANK YOU!!!

You were right what I did wrong was I NESTED it incorrectly, now its outside LOOP but inside for each and works! <3 THANK YOU

1 Like

BTW, how can I add
image

“;” ?

@anon40731888

Use like this str_output + ";" + str_Name

And you would get an extra semicolon may be …if so in write cell use str_output.Substring(1)

Cheers

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.