title: How to catch the error page in a website which throw System Error /Server Error In Selenium Webdriver c# and fail in my test case Nunit
body: <p>I have been trying to find ways to catch this error in my selenium webdriver c#.Is any method which will catch this error in my test case ? There is system error or Server Error but I am unable to retrieve my error and fail my test cases. All my test cases which have these error (System/Server) end with the result = "Test Passed" instead of showing of the Error.</p>
  
  <p><a href="https://i.stack.imgur.com/0qrgW.png" rel="nofollow noreferrer">Eg: Click to View ServerError</a></p>
  
  <p><a href="https://i.stack.imgur.com/oxDrL.png" rel="nofollow noreferrer">Eg: Click to View System Error</a></p>
  
  <pre><code>[Test]
  
      public void TestYamaha()
      {
          driver = new ChromeDriver();
          driver.Navigate().GoToUrl("http://192.161.0.1/iels-admin-dev/Login/Login.aspx");
          driver.Manage().Window.Maximize();
          driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
          driver.FindElement(By.Id("ctl00_MainContent_ucLogin_txtUserID")).Click();
  
          driver.FindElement(By.Id("ctl00_MainContent_ucLogin_txtUserID")).Click();
          driver.FindElement(By.Id("ctl00_MainContent_ucLogin_txtUserID")).SendKeys("manteng");
          driver.FindElement(By.Id("ctl00_MainContent_ucLogin_txtPassword")).SendKeys("Nic15742368");
          driver.FindElement(By.Id("ctl00_MainContent_ucLogin_cmdLogin")).Click();
          Thread.Sleep(2000);
          driver.Navigate().GoToUrl("http://192.161.0.1/iels-admin-dev/Announcement_News/Announcement_News_Search.aspx");
          Thread.Sleep(2000);
          driver.FindElement(By.CssSelector(".ui-datepicker-trigger:nth-child(2)")).Click();
          Thread.Sleep(2000);
          driver.FindElement(By.CssSelector(".ui-icon-circle-triangle-w")).Click();
          Thread.Sleep(2000);
          driver.FindElement(By.LinkText("1")).Click();
          Thread.Sleep(2000);
          driver.FindElement(By.Id("ctl00_MainContent_cmdSubmit")).Click();
               Thread.Sleep(2000);
          driver.FindElement(By.CssSelector(".clsDataGridAltData a:nth-child(2) &gt; img")).Click();
          Thread.Sleep(2000);
          driver.FindElement(By.Id("ctl00_MainContent_cmdSubmit")).Click();
          Thread.Sleep(2000);
      }
  </code></pre>
  
  <p>This code shows System Error (As shown in the picture) but how I show in my test case.</p>