How to store username and password to a variable from notepad file?

Hi ,
Can anyone please give me some idea that how to store username and password to a variable which is in the notepad file?

I saw one Topic regarding this like how to store a specific text but in my case I don’t know how to store username and password …I mean I want to know the expression…

In one topic they have stored invoicedate and invoice number in the assign activity like this:
InvoiceDate= System.Text.RegularExpressions.Regex.Match(Result,“(?<=(Invoice Date:)).“).Value
InvoiceNumber =System.Text.RegularExpressions.Regex.Match(Result,”(?<=(Invoice Number)).
”).Value.
I have tried but am not getting any idea…so I want to know the expression like this… which one should I want to replace?

Hi @indhu.p01

Can you show us the structure of the content of the text file?

1 Like

Hi @indhu.p01,
I think this is what you could do:
image
image
image
However keeping data like credentials in plain text is not the best idea :wink:

2 Likes

for trial I have simply given like:
Username: Abcd
Password: 1234
But I want like it should accept any characters…both for username and password.

Hi @indhu.p01

I think @Pablito’s answer will work for your scenario :slight_smile:

1 Like

yeah I will try this…

Thanks

1 Like

@Pablito
Is this for both username and password?

Yes it is. The expression is taking both. Then each one (username and password) is kept in separate group. As you see in my example I’m taking username by using (0) index and password by (1).

1 Like

yeah okie…

Hi @Pablito
Instead of passing both in writeline I want to pass in Type into activity…for that how should I want pass?

Well… actually the same.
image
Remember about Simulate Type attribute.

1 Like

@Pablito
But it is throwing error like regex is a type cannot be used as an expression…

In my example “regex” is an output attribute from matches activity. You need to set it in your project accordingly.
image

1 Like

Thanks @Pablito
I did the same but now it Is throwing error in type Into activity that “object reference not set to the instance of an object”?
Actually am new to Ui path so that why am asking these much questions.

Regards,
Indhu

Your output from Matches activity should refer to the actual variable. See my screen above.

Yes I have given the same…as you did…again it Is throwing the same error…in matches input “text” is the output from read text file right?

Yes exactly.

yeah I have given correct inputs and outputs…

Can you show your workflow? If any sensitive data is there, please just remove it.

Trial.xaml (8.8 KB)
Here in read file text you give your notepad file path and in open browser activity you give any url having “login page” consisting of Username and Password alone.