yury_mokropulo
13 years agoNew Contributor
How to close ALL browsers?
Hello!
I need to close all browsers (if any) before new test begins.
I wrote simple function:
function CheckBrowser()
{
var page = Sys.Browser("*").Page("*");
if(page) Sys.Browser("*").Close();
}
Obviously, it closes only one first browser from Object Browser list.
I tryied to put it in cycle:
function CheckBrowser()
{
var arr = Array("iexplore", "firefox", "chrome");
for(var i in arr)
{
var page = Sys.Browser( arr i ).Page("*");
if(page)
{
Log.Message("Browser '" + arr i + "' is open. Closing browser");
Sys.Browser( arr i ).Close();
}
}
}
//NOTE: there must be square brackets in arr i
But it needs all browsers from array list to be open, otherwise error appears:
"Unable to find the object Browser("firefox")"
Is there any way to find and close all browsers?
Thanks.
I need to close all browsers (if any) before new test begins.
I wrote simple function:
function CheckBrowser()
{
var page = Sys.Browser("*").Page("*");
if(page) Sys.Browser("*").Close();
}
Obviously, it closes only one first browser from Object Browser list.
I tryied to put it in cycle:
function CheckBrowser()
{
var arr = Array("iexplore", "firefox", "chrome");
for(var i in arr)
{
var page = Sys.Browser( arr i ).Page("*");
if(page)
{
Log.Message("Browser '" + arr i + "' is open. Closing browser");
Sys.Browser( arr i ).Close();
}
}
}
//NOTE: there must be square brackets in arr i
But it needs all browsers from array list to be open, otherwise error appears:
"Unable to find the object Browser("firefox")"
Is there any way to find and close all browsers?
Thanks.