Forum Discussion

saurabh1484's avatar
saurabh1484
Contributor
13 years ago

How to Get Instance of new opened IE instances

Hi,



I am working on Internet Explore version 8 and below is the scenario

1. I am opening a new instance of internet explorer.

2. I want to capture that instance and perform operations on that page.



Problem:

Is there any way so that i can get the count of already opened IE instances? If yes, can you give me the code in C#.

If the new instance is opened in TAB, how do i capture my page ?

1 Reply

  • ArtemS's avatar
    ArtemS
    SmartBear Alumni (Retired)
    Hello Saurabh Agrawal,

    >>1. I am opening a new instance of internet explorer.

    >>2. I want to capture that instance and perform operations on that page.

    You can launch a new instance of any tested application through passing the optional Count and IgnoreRunning parameters to the TestedApp.Run method:

      

    ...

      // Launch the Internet Explorer browser and capture that instance

      iexplore = TestedApps["iexplore"]["Run"](1, true);

      page = iexplore["ToUrl"]("http://www.smartbear.com/");

      page["Wait"]();

      //  Perform operations on the page

      ...

      // Close the instance of Internet Explorer we have started

      // At that, the other instances of IE are left running

      iexplore.Close();





    >>Is there any way so that i can get the count of already opened IE instances? If yes, can you give me the code in C#.

    >>If the new instance is opened in TAB, how do i capture my page ?

    Some time ago, we published a tech-article describing the specifics of tabbed browsers and the multi-process nature of IE8:  Web Testing and Tabbed Browsers.

    Namely, this article contains samples demonstrating how to list all already opened IE instances and how to manage page tabs. The samples in the article are provided in JScript, however, they can be easily transformed to C#Script, or be called from C#Script without any transformations at all.





    Regards.