cancel
Showing results for 
Search instead for 
Did you mean: 

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

Ryan_Moran
Valued Contributor

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

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);


 }


}


''-Praise the sun and Give Kudos.''
Ryan_Moran
Valued Contributor

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

It's Monday...corrected iteration...simplified previous example..







closeBrowser('iexplore');

closeBrowser('chrome');

closeBrowser('firefox');




function closeBrowser(browsername){


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


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


 if (myBrowsers.Exists){


  myBrowsers.close();


  }


 }


}


}






''-Praise the sun and Give Kudos.''
New Here?
Join us and watch the welcome video:
Top Kudoed Authors