How to get random username to fill from txt file


#1

Hi. I have 1 txt file with thousands of username. So how i do to get random username to fill form. Thank so much.


#2

HI @lehunglam,
In text file how it will look like the usernames.

If the username present like one by one use below code
arrvalue= strvalue.Split(Environment.NewLine.ToArray, StringSplitOptions.RemoveEmptyEntries)
else if you have the value with comma superated
arrvalue= strvalue.Split(","c, StringSplitOptions.RemoveEmptyEntries)

username= Convert.Tostring(arr1[random.Next(arrvalue.Length)])

Regards,
Arivu


#3

Thank so much @arivu96, i will try.


#4

Hi @lehunglam,

you need to create one Random variable->randomvar

randomvar= new Random()

intrandom=Convert.Toint32(randomvar.Next(arr1.length))

username =Convert.Tostring(arr1(intrandom))


#5

Hi @arivu96, I am new in Uipath, i can’t understand how to do, this is a shame.
Could you please upload a example for me ?
The username file present one by one
Thanks you so much


#6

HI @lehunglam,

refer the below example

Main.xaml (13.1 KB)

text file look like
arivu
anbu
malai
akila
archana
sri
lalitha
chand
bala
arun
raja
karthick

Regards,
Arivu


#7

That’s very nice, it work well, thank @arivu96 once again.