Q: How to detect if connection is unsuccessful using Watin? I have a project about going to a website. If the website cannot because of  several reasons, such as not being connected to the Internet, wrong proxy ip, etc,  the browser will show a page with text "You're not connected to a network". In this situation, I want to auto refresh the  browser. How will the program detect that website can't be loaded? 
Take a look at my below code:
   public void exam()
        {
            var ie = new IE();
            ie.GoTo("http://search.yahoo.com");
            ie.WaitForComplete(5);            
            if (ie.ContainsText("You're not connected to a network"))
            {
                ie.Close();// or ie.Refresh()
            }

        }  

It doesn't work. 

A: Try testing to see if you can Ping the address first ... try using this     
   public bool CanConnect()
   {
    var ping = new Ping();
    var reply = ping.Send("search.yahoo.com");
    return reply.Status == IPStatus.Success;
   }

or if you want to pass the address as a parameter:
   public bool CanConnect(string addressToTest)
   {
    var ping = new Ping();
    var reply = ping.Send(addressToTest);
    return reply.Status == IPStatus.Success;
   }

