Need Code for when my test fails

Best practices, code snippets for common functionality, examples, and guidelines.
Posts: 1
Joined: Thu Oct 11, 2018 6:34 pm

Need Code for when my test fails

Post by tyjaol » Thu Oct 11, 2018 6:38 pm

need code for when my test fails with 1 browser tab open it opens another browser tab on when it fails because my teardown only works with 2 browser tabs open at the time of teardown.

User avatar
Posts: 50
Joined: Wed Jul 27, 2016 12:22 pm
Location: Hamburg

Re: Need Code for when my test fails

Post by Andymann » Fri Oct 12, 2018 6:59 am

It looks like your Repo itm which is identifying your browser window isn't the best one.If it's IE you might go with this rxpath:

/form[@windowtext<' - Internet Explorer']

if it's firefox then


or - if all fails you might use this bit of usercode which kills every process starting with the given string (case sensitive):

Code: Select all

        public static void KillProcessStartingWith(string pProcessName){
        	String sExeName;
        	Process[] tmpProc;
        	Process[] processes = Process.GetProcesses();
        	if((processes!=null) && (processes.Length>0)){
        		for(int i=0; i<processes.Length; i++){
//        			Report.Info( processes[i].ProcessName );
        				sExeName = processes[i].ProcessName;
        				tmpProc = Process.GetProcessesByName( sExeName );
        				for(int j=0; j<tmpProc.Length; j++){

Vorsprung durch Wahnsinn