For each or iteration doubt

Hello,

Can you please help me on finding the solution for the below requirement.

I have Site A and Site B. and I have 3 log in credentials for site A and 3 log in credentials for site B.
For both the sites all the 3 login credentials are having same username.
So if i log in with 1 credential for Site A, I have to use same Site A’s Username for Site B.
But if Site B fails to open, i will have to use other two credentials to open Site B.
Can you guys help me on this.

kindly suggest.

Regards,
Vasan

Hello @Yoganathan_Mohanavasan,

Interesting scenario, Ideally I would work with my business analyst and the system admin if there is a way to have just a dedicated access for the robot(s)

if the above is not possible, this is might be my approach:

Site A

  • use a do while loop through the credentials
  • Identify if site A logged in successful with element exist and then save the working credential to a variable
  • break the loop when you have identified is done or when you have tried all credentials

Site B

  • try to log in to site b with the credential matching site A
  • use element exist to verify you logged in successful
  • if the login failed, use the steps described above to loop through site b remaining credentials

If you provide more context on why you need to do this, perhaps I would be able to provide a simpler solution (like using value per robot assets for example.)

Hi Edwin,

Thank you for the suggestion, I am elaborating little more for your better understanding.

I have to log into citrix with the help of three different credentials, its a business requirement, each credential needs to be tried twice for successful login before picking up the next credential.
If the 1st log in fails it tries again even if its fails it throws an exception and picks the next credential thats how i built the model.
but.
Second site also has 3 different credential, as per business requirement same UserID used in citrix to be used in second site.

I am calling all 3 credentials through asset.

if i try to set a condition like.
Getting a successful user id from citrix login and in For each loop checking if second site asset has same user id or not, if matches it executes the sequence.

but client also requires if the user id fails it has to take the next credential for site B and try executing it.

this is where i am stuck.

can you help me in this please.

Regards,
Vasan.

Put the 3 asset names into an array. Loop through the array with For Each, get the credential, try to log in. Use Check App State to verify login, and if successful Break from the For Each.

Hi,

considering your points, the previous solution should satisfy your needs. You may build a temp data structure (a list or a datatable) to iterate through the credentials.

For example
you have a list of credentials :

SiteBCredendials= ["cred1", "cred2", "cred3"]

and you know cred2 worked for logging into citrix.

Then you could try to authenticate to site b with cred2 and if it fails loop trough the remaining credentials, you can create a sub list usling Linq and iterate over it with for each or do while

remainingCredentials = SiteBCredentials.Where(Function(cred) cred <> "cred2")

Thanks Edwin

1 Like

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