specflow - Killing all iexplore processes after test run fails -


when run our codedui tests , test cases fail kill internet explorer process calling kill() below:

private static readonly hashset<string> processestokill =      new hashset<string>(new[] { "iexplore" });  public static void kill() {     var runningprocessestokill = (from p in process.getprocesses()         processestokill.contains(p.processname,              stringcomparer.ordinalignorecase)         select p).toarray();      // first try close process in friendly way     closeprocess(runningprocessestokill);      // wait while give processes time terminate     waitforprocess(runningprocessestokill);      // if not closed kill process.     killprocess(runningprocessestokill); } 

killing done calling closemainwindow() , close() on processes first, waiting while , calling kill() on processes.

unfortunately, not close javascript alert popup. when test run finished remains in screen blocking next test, so:

popup remains in screen

why not close alert, , how can fix this?

you can brute force using taskkill command command line:

c:\>taskkill /f /im iexplore.exe 

this, of course, doesn't tests. instead, use process.start(...):

public static void kill() {     system.diagnostics.process.start("taskkill", "/f /im iexplore.exe"); } 

this shut down internet explorer processes, regardless of whether or not have alert or confirm dialog visible.

references:


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -