There are a lot of tests in a testlist.When a test fails due to a fact that the browser is not responsing or the browser can not be closed,the other tests after the test can not be executed.So i just want to know how to close the browser when the browser is not responsing,so that the other test can be executed.
Thanks for your answer.
5 Answers, 1 is accepted
If you're dealing with a Test Studio test, you can try putting your tests into a Test List and then setting the "KillBrowserProcessOnClose" setting in the Test List settings as shown in the attached screen shot.
If instead you're dealing with a 100% coded test, you'll need to do a Google search for how to find and kill processes. We, Test Studio technical support, don't have the expertise how to do this via code.
Cody
the Telerik team
Test Studio Trainings
Hello Cody,
I have a problem to open browser after killing browser process.
test case:
1 test: open page, then open HTML popup.
after test finished, browser processes succesfully killed, but in second test new browser instance doesn't start.
Here code which run before each test.
if
(Manager.Current.Browsers.Count > 1)
{
Helpers.KillBrowserProcesses(_browserType);
}
if
(ActiveBrowser ==
null
|| !Process.GetProcessesByName(_processName).Any())
{
var retries = 0;
bool
browserOpened;
do
{
try
{
browserOpened =
true
;
Manager.LaunchNewBrowser(_browserType,
true
, ProcessWindowStyle.Maximized);
retries = 0;
}
catch
{
retries++;
browserOpened =
false
;
Console.WriteLine(
"Restarting the browser. Retry {0} of {1}"
, retries,
Configuration.Instance.BrowserOpeningRetries);
if
(Manager.Browsers.Count <= 0)
continue
;
Helpers.KillBrowserProcesses(_browserType);
//foreach (var browser in Manager.Browsers)
// browser.Close();
//if (ActiveBrowser != null)
// ActiveBrowser.Close();
}
}
while
(retries < Configuration.Instance.BrowserOpeningRetries && browserOpened ==
false
);
}
public
static
void
KillBrowserProcesses(BrowserType browserType)
{
var browserProcesses =
new
Process[] {};
switch
(browserType)
{
case
BrowserType.FireFox:
browserProcesses = Process.GetProcessesByName(
"firefox"
);
break
;
case
BrowserType.InternetExplorer:
browserProcesses = Process.GetProcessesByName(
"iexplore"
);
break
;
}
foreach
(var browserProcess
in
browserProcesses)
{
try
{
browserProcess.Kill();
browserProcess.WaitForExit();
}
catch
{}
}
}
I used the same implementation of the KillBrowserProcess method in a similar scenario, but I wasn't able to reproduce the problem you are experiencing. Would it be possible for you to send us a small executable demo project that replicates the issue, so that we can try to determine what is causing the problem?
All the best,
Plamen
the Telerik team
Test Studio Trainings
Hello Plamen.
I resolve my problem by added these strings
var manager =
new
Manager(settings);
manager.Start();
I am glad to hear you got it working! Thanks for the update.
Kind regards,
Plamen
the Telerik team
Test Studio Trainings