How to fix close browser issue?

while UiPath scrapping the eportal incometax, and in some screens if the selector fails UiPath trying to close the browser, in this case, the logged in website is closed without logged out. And to close the browser, the broser is popuping the alert message to close or cancel. the browser gets closed only pressingthe enter key or clkcing on close in the ui. how to resolve this issue?

can anyone help to fix this, i need the UiPath workflow to properly logout the portal and then close the browser.

Hello @Prabhakaran_Elango,

Please enclose this automation inside a try-catch block and disable the option to close the application/browser automatically. In the finally block, ensure that both logout and close operations are included so that, irrespective of success or failure, it will always log out and close.

Thanks,
Karthik

but when i use those activities in finally block, i need to use open application/browser activity again right? then how can i logout the currently logged in window?

You can handle this by adding a proper cleanup flow in UiPath.

Step 1: Put your scraping activities inside a Try Catch block.
Step 2: In the Try section, perform the normal scraping steps.
Step 3: In the Catch section, log the error, but do not close the browser immediately.
Step 4: In the Finally section, add steps to logout from the income tax portal first.
Step 5: After logout, use Close Tab / Close Application to close the browser.
Step 6: If a browser confirmation popup appears, use Check App State / Element Exists to detect it.
Step 7: Then use Send Hotkey = Enter or click the Close/Leave button on the popup.
Step 8: Only after that, close the browser completely.

@Prabhakaran_Elango * After logout, use:

  • Check App State / Element Exists to detect the alert
  • then Send Hotkey = Enter or click the Close/Leave button on the popup
  • Use Attach Browser / Use Application-Browser properly
    Make sure all activities are inside the same browser scope, so UiPath works on the correct tab/window

Please mark the option ‘Never’ for the application/browser. Please see below:

When set to ‘Never’, it will attach the existing browser instance, and you will not be prompted to log in again.

These Open and Close options under Properties will help you handle the browser session.

Thanks,
Karthik

@Prabhakaran_Elango

ideally in your catch or finally you need to have the logout sequence…

two ways

  1. have try catch inside the use app/browser this way no need to use another use app/browser
  2. if try catch is around sue app browser, use the property open never ..so that it attaches to the browser that is present

cheers

@Prabhakaran_Elango

Here inside of Open application/browser activity use try catch then implement all of your business steps inside of try block and then in catch block build steps that what you need to do when getting the exception. and then implement logout steps final block this will make sure even if any exception occurred or not execution will ensure the logout steps.

Hi @Prabhakaran_Elango

Could you try to wrap the Use Application/Browser container inside a Try/Catch block and set the Close property to Never.
Define a variable for the Output Element and make sure the scope is set wide enough.
Inside the Finally block you create a new Use Application/Browser container with the Input Element from earlier, and create your log out/close sequence there.

Regards
Soren