title: WatiN extensions for H1 H2 H3 for Form, Browser and Frame
body: <p>I am trying to write extension methods in WatiN for H1, H2, H3 and UL, all these elements should be supported for Browser, Frame, Form and Div.
  My approach was to create different .cs file like FormExtensions.cs, FrameExtensions.cs and say DocumentExtensions.cs</p>
  
  <p>In my DocumentExtensions.cs , I include below code.</p>
  
  <pre><code>    public static H1 H1&lt;TDoc&gt;(this TDoc doc, string text)
          where TDoc : Document
      {
          ElementFactory.RegisterElementType(typeof(H1));
          return doc.ElementOfType&lt;H1&gt;(Find.ByText(text));
      }
  
      public static H2 H2&lt;TDoc&gt;(this TDoc doc, string text)
          where TDoc : Document
      {
          ElementFactory.RegisterElementType(typeof(H2));
          return doc.ElementOfType&lt;H2&gt;(Find.ByText(text));
      }
  
      public static H3 H3&lt;TDoc&gt;(this TDoc doc, string text)
          where TDoc : Document
      {
          ElementFactory.RegisterElementType(typeof(H3));
          return doc.ElementOfType&lt;H3&gt;(Find.ByText(text));
      }
  </code></pre>
  
  <p>While my FormExtensions.cs includes</p>
  
  <pre><code>    public static H1 H1&lt;TForm&gt;(this TForm form, string text)
          where TForm : Form
      {
          ElementFactory.RegisterElementType(typeof(H1));
          return form.ElementOfType&lt;H1&gt;(Find.ByText(text));
      }
  
      public static H2 H2&lt;TForm&gt;(this TForm form, string text)
          where TForm : Form
      {
          ElementFactory.RegisterElementType(typeof(H2));
          return form.ElementOfType&lt;H2&gt;(Find.ByText(text));
      }
  
      public static H3 H3&lt;TForm&gt;(this TForm form, string text)
          where TForm : Form
      {
          ElementFactory.RegisterElementType(typeof(H3));
          return form.ElementOfType&lt;H3&gt;(Find.ByText(text));
      }
  </code></pre>
  
  <p>Both the above classes are under same namespace.
  When I try to use and test the above extensions I get ambiguity issue.</p>
  
  <p><code>Console.WriteLine(browser.H1("h1 browser").Exists);</code></p>
  
  <p><code>Console.WriteLine(browser.Forms.First().H1("h1 form").Exists);</code></p>
  
  <p><code>Console.WriteLine(browser.Frames.First().H1("h1 frame").Exists);</code></p>
  
  <p>What should be the right approach to support all Div, Form, Frame and Browser?
  When I use only DomContainer then Browser and Form work.
  When I use only Document then Browser and Frame work.
  Waiting for your feedback!</p>