Support Portal

for ProcessRobot and WinAutomation

Start a new topic

Managing Multiple Web Browser Instances

ADMIN

Apart from reusing the 'Launch New (IE-Firefox-Chrome)' actions in a process to launch and manipulate multiple browser instances, you may want to use a loop and repeat the action.  The attached process is an example of how to utilize loops to launch browsers and methods to handle each instance.

 

When using the 'Launch New (IE-Firefox-Chrome)' action in WinAutomation or ProcessRobot in a loop, each launch is associated and stored with the default instance variable %Browser% (this variable name can be altered as required).  Each new browser launched in the loop will be assigned to the variable %Browser% at launch time, however, will contain a unique ‘WebBrowser Instance’ property %Browser.handle% regardless of what web page you navigate to.

 

The attached example parses set variables applying regular expressions, which stores each URL into a %Match% variable, that is subsequently added to a %URL% list within a ‘For Each’ loop.  This part of the process is handled in the ‘URL List’ function.

 

In the Process Designer Variables window, you will notice the %Browser_Handles% list values appear to be the same to the naked eye ‘WebBrowser Instance’, however, it is important to note that each one of these similar values contains a unique underlying handle ID value as previously mentioned.  When running the attached process, you will notice that browsers opened between actions 5-9, will be closed in the same order between actions 20-22.  You can enable action 8, which allows you to view the %Browser.Handle% ID after each launch in a message box if desired (or, the value can also be viewed in the variables window).

 

The Region ‘Focus Windows First to Last’ orders the browser instances opened from first to last, by calling each window to the front using the %Browser_Instance[‘List Index Value’]% variable along with the corresponding list index.  Note that you can apply any applicable web action to any browser using the same variable.

 

Region ‘Close Browsers in order they were opened’ uses a for each loop to iterate through all %Browser_Instance% list values and sequentially close each open browser in the list.

waj

1 person likes this idea
1 Comment

Hello, Dimitris.


Can an instance of a browser be created by the value of this handle? I was thinking about passing pointers/handlers to compiled bots using arguments. I know that the URL can be used to attach a browser instance to an existing browser. However, using the handler seems to be a cleaner way to deal with this.


Thank you in advance.


Login or Signup to post a comment