Forum Discussion

pmallela2's avatar
pmallela2
Contributor
9 years ago

How to handle multiple instances of same application

I have a question,how to handle multiple instances of same application.

for example : if i open notepad three times,i need to enter a value in the first  opened one,next in third opened one,next second.how we can handle this type of scenarios

5 Replies

  • Each instance will have a new index number.

     

    Use that as an identificatiojn property. You still need to take care that you track and manage them properly in your test.

     

    I use multiple browsers. I always start the browser with a locator page (very simple HTML file I prepared) so I can find the browser with that open, and then navigate it elsewhere. After that, I track them by their URL in use. If they were all using the same URL, I would have to use the index number of the top level process.

    • Ravik's avatar
      Ravik
      Super Contributor

      Hey Colin_McCrae,

       

      Can you share the code for same (Multiple instances of browser)

      • Colin_McCrae's avatar
        Colin_McCrae
        Community Hero

        Not much code to share really?

         

        Using VBScript and a Windows Shell object to launch the executable ....

         

        For Internet Explorer:

         

        <Shell Object>.Run(project.Variables.<browser-in-use> & ".exe " & Project.Variables.<path-to-HTML-file> & "page.html", 1)

         

        For Chrome:

         

        <Shell Object>.Run (project.Variables.<browser-in-use> & ".exe --disable-hang-monitor --new-window file:///" & replace(Project.Variables.<path-to-HTML-file>, " ", "%20") & "page.html")

         

        ... and you would probably need to modify again for FireFox. I don't use that. (The IE version may be out of date? Not run this against IE for some time now. Not sure if it would cope with a file path with spaces in it ... the Chrome one will.)

         

        The two project variables specify the browser in use (is used elsewhere) and the location of the basic little HTML file (which is literally about 4 lines long - just a basic 'You are on the Automation start page ...' type thing.)

         

        Once loaded it simply finds the browser displaying the locally hosted HTML file. Resizes and locates as required. Then navigates elsewhere. Once navigated away from the start page (which is used solely for identification purposes) each browser/page is addressed by it's URL as they are all different.

         

        If they are all on the same URL, you need to use something else. (As I mentioned above.)

         

        So not much to say really? It's pretty straightforward. No fancy code. It's more about technique than code.

  • There are several options with the simplest being to utilitize the TestComplete defined index assigned to each instance of Notepad. Another suggestion would be to store a user defined index and process Id in an  ArrayList.