title: How to handle testing an HTML control that lacks sufficiently unique attributes?
body: <p>I'm using Coded UI Test to test a web application.</p>
  
  <p>I have a class <code>Locator</code> that I use to stash the specifics needed for CUIT to find a control.  To operate on a control, a page object specifies the locator, not the control, and lower-level functions find the control and perform the operation. </p>
  
  <p>Right now, my class has:</p>
  
  <ul>
  <li>Locator name.</li>
  <li>One or more attrName/attrValue pairs that can locate the HTML element for the control.</li>
  <li>An operator (Contains or EqualTo) that specifies the matching needed.</li>
  </ul>
  
  <p><strong>The problem:</strong>  Some of the controls I need to operate on don't have enough unique attributes to allow them to be found.  (Yes, I know the developers should improve their HTML, but I don't control that.)  I have been using a locator to find a nearby element, then "walking" in the DOM to get to the element I want.  I hate having this DOM-walking code in my page object, even factored into a function.</p>
  
  <p><strong>A possible solution:</strong>  I'm considering enhancing class <code>Locator</code> so that it can have either the attrName/attrValue pairs <strong>or</strong> a reference to a function that has the DOM-walking code.  One advantage of this is that the page objects would always use a locator object.  Another is that when the HTML is improved, the locator could change from DOM-walking code to attrName/attrValue pairs, which would be transparent to the page object.</p>
  
  <p>Still, I think this may be over-complicated.</p>
  
  <p>Is there a better solution to this problem?</p>