Forum Discussion

dbaechtel's avatar
dbaechtel
Contributor
12 years ago

Why do I get "The Browser is already running." ?

I have made a series of Keyword Tests. Each test Closes the Browser at the end of the test. Each Keyword Test runs without error individually.

I have added the Keyword Tests to my Test Project and when I try and run the Test Project, on the start of the 2nd test I get the error "The Browser is already running." and "Cannot obtain the window with the window class 'IEFrame', window caption '*' and index 0." and the test stops.

I have verified that indeed the Browser was closed at the end of the 1st test and before the 2nd test is started. Also no other browsers are running.

Why am I getting this error and how do I get around it so that all tests will run in succession?

11 Replies

  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor
    Example of a "safer" method of closing all browsers. This is an alternative to terminating the process and you could replace .close() with .terminate() if desired.



    //JScript


    closeBrowser('iexplore');


    closeBrowser('chrome');


    closeBrowser('firefox');



    function closeBrowser(browsername){

    var myBrowsers = (new VBArray(Sys.FindAll('Name','*' + browsername + '*',1,true))).toArray();


    var closedBrowsers = 0;


    for (var c = 0;c < myBrowsers.length;c++){


     if (myBrowsers[0].Exists){


      myBrowsers[0].close();


      closedBrowsers++;


      BuiltIn.Delay(1000,'Waiting for browser to close...');


      }


     }


    if (closedBrowsers){


     closeBrowser(browsername);


     }


    }