2
當我們運行CodedUI測試和測試案例失敗,我們通過下面的調用Kill()
殺死Internet Explorer進程:殺試運行後,所有IEXPLORE進程失敗
private static readonly HashSet<string> ProcessesToKill =
new HashSet<string>(new[] { "iexplore" });
public static void Kill()
{
var runningProcessesToKill = (from p in Process.GetProcesses()
where ProcessesToKill.Contains(p.ProcessName,
StringComparer.OrdinalIgnoreCase)
select p).ToArray();
// First try to close the process in a friendly way
CloseProcess(runningProcessesToKill);
// Then wait for a while to give the processes time to terminate
WaitForProcess(runningProcessesToKill);
// If not closed kill the process.
KillProcess(runningProcessesToKill);
}
殺戮完成由呼叫CloseMainWindow()
和Close()
首先進程,然後等待一段時間,然後在進程上調用Kill()
。
不幸的是,這並未關閉JavaScript警報彈出窗口。當測試運行結束,這仍然在屏幕遮擋下一個測試,像這樣:
爲何不關閉警告,以及我們如何解決這一問題?