My UiPath workflow is taking list of crednetials for portal login by the api call, and using thos credentials in for each loop activity in UiPath studio. it workf like it login to one crednetials process data scrapping for that crednetial then logout from the portal and login for the next credentials. In this flow if any issue comes for any credentials while scrapping the data, my UiPath workflow stops its exeution. I need my workflow continue execution for the next credentials and logout for the credentials which got an issue. how to achive this ?
Use Try Catch inside the For Each loop so that if scraping fails for one credential the error is handled, logout is executed, and the workflow continues with the next credential.
Like below:
For Each credential
Try
Login
Scrap Data
Logout
Catch (Exception ex)
Log Message (“Failed for this credential”)
Logout (safe logout)
End Try
Next…
Happy Automation
Add a try catch inside the for each and inside the try section add your scrapping logic.
Hello @Prabhakaran_Elango
You could wrap your Loop Body in a Try/Catch, and have logic for “starting over” in your Catch block (eg. close/open app, Continue activity etc.).
Regards
Soren
Put the entire scraping sequence inside a Try-Catch placed inside the For Each loop.
If the workflow fails for one credential using retry scope try it for 2-3 times , if it fails again, then handle the error and allow the loop to continue to the next item instead of stopping the whole process. You can even use continue to skip the current iteration or use catch block.
This ensures execution will happen for each item even when some accounts fail.
but its browser portal login im using open browser activity. so im logout fromthe portal by clicking the logout button in the portal. From your logic, if i user the clicking logout activity in catch block, it may cause issue because the uielement can only be accesble inside the browser activity right?
You don’t have to logout necessarily, also login before For each, this will make design even simple.
Hi,
Your workflow should look like this:
For Each credential in CredentialsList
Try
Login (using this credential)
Scrape data
Catch ex
Log error → “Scraping failed for XXX credential”
Finally
Logout (always runs even if Try failed)
End For Each
Why this works?
- Try runs your login + scraping.
- Catch prevents your workflow from stopping when an error occurs.
- Finally ensures logout runs even when scraping crashed.
first thing instead of you loopin gon creds create process which is linear and then add queue items as the cred details or so so that the same process runs for each cred
apart from that if you still want to loop
then have open browser inside loop and keep all activties in it iun try catch..in catch you can close the browser or kill
cheers
