title: Selenium testing using C#: assertions. Why am I getting the following error?
body: <p>using System;
      using System.Text;
      using System.Collections.Generic;
      using System.Linq;
      using Microsoft.VisualStudio.TestTools.UnitTesting;
      using System.Text.RegularExpressions;
      using System.Threading;
      using Selenium;</p>
  
  <pre><code>namespace Search1
  {
    [TestClass]
    public class SearchTest1
    {
      public SearchTest1()
      {
  
      }
  
      private TestContext testContextInstance;
  
      /// &lt;summary&gt;
      ///Gets or sets the test context which provides
      ///information about and functionality for the current test run.
      ///&lt;/summary&gt;
      public TestContext TestContext
      {
          get
          {
              return testContextInstance;
          }
          set
          {
              testContextInstance = value;
          }
      }
  
      private ISelenium selenium;
  
      [TestMethod]
      public void SearchMethod1()
      {
  
  selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://localhost/crm.aspx");
          selenium.Start();
          selenium.Open("/crm/SearchPage.aspx?function=3");
          selenium.WaitForPageToLoad("30000");
          Assert.IsTrue(selenium.IsTextPresent("Select All  |  Clear All"));
          try
          {
              Assert.IsTrue(selenium.IsTextPresent("Select All  |  Clear All"));
          }
          catch (Exception)
          {
  
          }
   selenium.Click("//span[@onclick=\"fnCheckGroupWithMessage('You have selected all items.', 'cbxRepeater_');\"]");
          Assert.AreEqual("'You have selected all items.", selenium.GetAlert());
  
          decimal totalCheckboxes = selenium.GetXpathCount("//input[@type='checkbox']");
  
          for (int i = 1; i &lt; totalCheckboxes + 1; i++) 
          { 
              Assert.IsTrue(selenium.IsChecked("//input[@type='checkbox'][" + i + "]")); 
          }
  
      }
   }
  }
  </code></pre>
  
  <p>Test method Search1.SearchTest1.SearchMethod1 threw exception: 
  Selenium.SeleniumException: ERROR: Element //input[@type='checkbox'][2] not found</p>