Ask a Question

Two browser instances at the same time

Occasional Contributor

Two browser instances at the same time

Hello all,

I have some tests that requires working with two browsers windows/instances at the same time for user sync tests. It works well with IE since I can identify browser instances by the O.S process. For example:

Set myRootObject = Sys.Process("iexplore", 1).Page("myapplication")

Set myRootObject2 = Sys.Process("iexplore", 2).Page("myapplication")

In this way, I can interact with two windows of the same browser at the same time.

The problem comes when trying to do the same with Firefox since no matter how many Firefox browser you are running you get only one firefox.exe process instance.

How can I make concurrent tests, so I can interact with two or more windows of the same browser in the same test?

Thanks to all.

Guys, did you find a solution on this?


I am trying to open two browsers and then to switch between them using BrowserWindow.SetFocus()


While focus is switches between browser windows the actual focus keeps the last browser instance and all interactions goes there.

Regular Contributor

From what I understand what you're trying to test is an 'application feature'.


" The test goal is to verify that when one user is doing an specific action on that page (seting a textbox for instance), another user can't do the action (setting the same textbox) because the application blocks some actions when some user is doing it."


Couldn't you do this by opening 2 different browsers and doing the same activity? I don't see how using the same or different browser changes any test results but your life will be much easier by using 2 different browsers.


e.g. firefox and ie.


You can always switch browsers and re test to add another test case.



I raised a ticket with Smartbear about this.


With multiple browsers, focus and "bringing to front", has not been handled properly in Chrome (not sure about other browsers) since they stopped using the NPAPI plugin.


They recreated the problem and it should be fixed in the next release.


I'm using Chrome and my current workaround is to find the BrowserWindow object with the correct caption (mine are all different) and then apply the "Activate" method to that BrowserWindow. This activates the right browser for me and focus is correct. Not ideal, but it will work for me until they fix it.


Which browser are you using?

Hi Colin,


Thanks for replay.


I am using IE 11 and FireFox 38.



Of course. The two I don't use! Smiley LOL


Have you tried using "Activate" rather than "SetFocus"? (Assuming they support this method ...)


I found SetFocus didn't work for me. Hence my use of Activate instead.





Activate() and SetFocus() are different things. SetFocus() just sets the keyboard input focus to the given control while Activate() makes the window active and puts it in the front of all other windows. The above means that: a) Not all windows can be activated (e.g. MDI ones usually cannot); and b) the OnUnexpectedWindow() event is triggered if the given window cannot be activated (e.g. if it is blocked by some modal window). Note, that the OnUnexpectedWindow() event is not triggered if SetFocus fails to set the focus to the target control. The above makes it a standard coding practice (for desktop applications) to call Activate() at the proper places to ensure that no modal (usually - error or warning) windows are displayed.


The function from worked fine for me for all windows-supported browsers (except Edge which I just did not check). However the referenced function relies on the caption of the target window...

  /Alex [Community Hero]
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
Showing results for 
Search instead for 
Did you mean: