UI Automation Browser Instance and Screen / Common Components Reusability

Description

The Practical Challenge in UiPath
When implementing this in UiPath—especially when dealing with multiple screens—we typically use the “Use Application/Browser” activity to create a browser instance by providing the application URL.
However, a challenge arises when we design reusable components in separate XAML files.

  • Problem Statement
    • I successfully create RegisterNewUser.xaml with arguments and initialize a browser instance.
    • When I create LoginToUiBank.xaml, I again use the “Use Application/Browser” activity with arguments.
    • UiPath creates a new browser instance instead of using the existing one.
    • As a result, I am unable to reuse the same browser instance created during the Given step.

Logical Structure of a Test Case
A typical BDD-aligned test case includes:
• GIVEN – Perform prerequisites (e.g., register in the UiBank application).
• WHEN – Call reusable components (e.g., NavigateToLoans.xaml, FillLoanForm.xaml).
• THEN – Perform validations (you may store values at the test case level and verify them here).


Note:
In the UiBank application, you may not immediately observe the issue of multiple browser instances because it supports direct URL navigation. This means you can navigate directly to the loan page even without being logged in.

However, real-world applications do not typically allow such behavior, which makes browser instance management critical.

  • The Major Challenge
    Maintaining a single browser instance across multiple reusable workflows (XAML files).

** My Solution Should look like this:

*** Solution Approach**
To resolve this, I implemented the following design:

  1. Created a Global Variable
    o Defined a global variable named Browser of type UiElement.

  2. Initialize Browser in Registration Workflow
    o In RegisterUser.xaml, used the “Use Application/Browser” activity.
    o Created a local argument lbrowser (In/Out scope as required).
    o Assigned lbrowser in the Output property of the activity.

  3. After completing all UI interactions (Click, Type Into, etc.), use an Assign activity.
    o Assigned the global variable GlobalVariable.Browser = lbrowser.

  4. Reuse Browser in Other Workflows
    o In subsequent workflows (e.g., Login, Navigation, etc.), again used “Use Application/Browser”.
    o Set the Open property to Never.
    o Assigned lbrowser in the Output property.
    o Reassigned the global variable with lbrowser to maintain consistency.(Use Assign Activity).

With this implementation:
• Only a single browser instance is maintained.
• No additional browser windows are created.
• Reusable XAML components function seamlessly.
• End-to-End scenarios can now be executed reliably.

*** Final UiPath Workflow Structure**
Instead of a monolithic implementation, the structure becomes modular:
• RegisterUser.xaml
(Arguments: FirstName, LastName, Username, Email, Password)
• LoginToUiBank.xaml
(Arguments: Username, Password)
• NavigateToLoanApplication.xaml
• FillTheLoanApplicationForm.xaml
• ValidateLoanApplicationStatus.xaml

*** As Against :**

ENJOY UI AUTOMATION !. . .

Date

2026-02-26

Related UiPath products

Automation Cloud

Hi
Is the challenge that you should be able to run the process i multiple times in parallel or just in 1 flow using the same browser?

If the first I think your solution would be fine.
If you “just” have to run the flow/proces in single browser, you could in the ‘Use Application/Browser’ use the URL in the selector, like this:


This would work if you only have 1 instance of uibank open.

Hi , this Problem is not with UiBank Application. for real life Application like Flipkart or amazon , you have Navigation and Screens. there if you use the second time “Use Application / Browser” another application open up.

Anyways the Implementation is for those who wants to Implement Gherkin: Reference | Cucumber Kind of Workflows. we have Achieved it and would be happy if someone need to connect.
BTW I am going to prepaire a Small Mockup , with any other application and attach the project here.