S Akin Sabak
S Akin Sabak

Reputation: 57

I need a conditional statement or Error handling that can exit the open browser

I am running tests with IBM RFT, when a test fails, the browser does not close. On a Windows machine this is a huge problem because I then have several instances of the browser still running in the background.

Upvotes: 0

Views: 134

Answers (1)

Roland
Roland

Reputation: 1240

You can create a super helper class in which you override the onTerminate-method. This method is always called after the termination of the testMain-method. To ensure that there are no browser instances running, I personally like to kill the respecting processes altogether. Maybe there are more subtile ways... Example of a super helper class killing IE on termination (Java):

public abstract class SuperScript extends RationalTestScript
{
    @Override
    public void onTerminate()
    {
        try
        {
            Process p = Runtime.getRuntime().exec("taskkill /IM iexplore.exe /F");
            if (p != null)
            {
                p.waitFor();
            }
        }
        catch (Exception e)
        {
        }
        super.onTerminate();
    }
}

Upvotes: 0

Related Questions