Forum Discussion

didacher's avatar
didacher
Occasional Contributor
10 years ago

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.

15 Replies

  • The other possibility I guess (seems like a nasty way to do it, but it should work) is to resize the browser as you start it, and make one 1 pixel taller/smaller than the other then use the height of the page to tell them apart?



    (I have a stored page in my project that I open all browser instances with so I can always spot the freshly opened one. So I always start on my stored page, do whatever I need to do - like resizing - the fresh browser, then navigate to the site I actually want to work on. If you use this method along with 1 pixel different sizing, you should get there.)
  • Are they on the same URL/page at all times?



    I run multiple version of browsers (IE & Chrome - Chrome is the same as FireFox, only ever one process) and I tell them apart using the URL as they are never on the same URL at the same time.



    I don't trust things like application instance/index. They've never been very reliable in my experience ....



    (Even if there was something different on the page, but the URL was the same, you could find that and then work your way up the tree to find the parent page ...)
  • didacher's avatar
    didacher
    Occasional Contributor
    Yes, they always relay on the same URL. I can't distiguish them by URL, it should be using some browser/window/process number or any other technique... The two browser windows work at the same page.



  • Same user logged in?



    Is there *anything* on the page that is different between the two?



    As I say, I've tried index and application instance in situations like this and always found it unreliable. Using something on the actual page and then backtracing to the parent would be the first thing I'd try if the URL's were identical ....
  • didacher's avatar
    didacher
    Occasional Contributor
    Yes, the same page and user.  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.



    So the same browser, two windows, two users doing the same action. User 1 can set the textbox, user 2 has the textbox disabled.
  • didacher's avatar
    didacher
    Occasional Contributor
    Re-pixelling the browser is not a good way...is there any property I can set to distinguish the two pages of the same browser when they got the same html content?
  • Not that I've found.



    You *should* be able to use application instance/index value. But when I tried it, it was useless. The numbers never seemed to match to the instances properly. Hence why I use my stored HTML file when I start the browser so I always have something to find which will identify the new browser.



    I agree that using slightly different browser sizes is not the nicest way to do it. But if you have nothing on screen to use, I'm struggling to think of anything else.



    You can control the browser size and location in your code when you start it (I do) so you can easily control the 1 pixel size difference yourself so it should work OK.
  • didacher's avatar
    didacher
    Occasional Contributor
    Finally I found a way



    In Internet Explorer work with process index



    Set browserWindow1 = Sys.Process("iexplore", 1).Page("myHomeURL")

    Set browserWindow2 = Sys.Process("iexplore", 2).Page("myHomeURL")



    In Firefox work with page index



    Set browserWindow1 = Sys.Process("firefox").Page("myHomeURL")

    Set browserWindow2 = Sys.Process("firefox").Page("myHomeURL", 1)



    That way I can interact with two different windows at the same page at the same running time.
  • Is it reliable?



    Last time I tried it that way, it wasn't reliable and kept focussing on the wrong window!



    If it works properly now, that's handy to know for future reference.
    • baxatob's avatar
      baxatob
      Community Hero

      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.

      • djadhav's avatar
        djadhav
        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.