I have a test harness written in C# using CUIAutomation and IUIAutomationElements to perform UI Automation.
I am pointing this test harness at HTML interfaces (both in IE and in a Silverlight HTML container, although I don't think this is actually germane to the conversation).
A number of HTML Input controls (Type = Text) are present on the page, but my harness and inspect.exe both fail to detect a useable Name ID. In hindsight, this matches the documentation available on MSDN, but that doco does not make a lot of sense. At http://msdn.microsoft.com/en-us/library/windows/apps/hh452706.aspx is a listing of the mapping of HTML 4 controls to UIA.
According to that page, an Input control where Type = Text will always have a Name = "". While this matches what I see in inspect, this doesn't make a whole lot of sense. In other words, using the Name property to identify an on-screen input control is impossible, since there is no uniquely identifying property that can be used to distinguish one control from another.
So, how is this intended to work? I am guessing I should be using an Automation ID instead, however, the same controls exhibit not such property via inspect.exe. Here is a sample of the HTML used to create the Input controls in question:
<input name="GeneralInfoPage$NameTextBox" type="text" maxlength="50" id="GeneralInfoPage_NameTextBox" class="detailText"
style="width:50%;" />
As you can see, both a name and ID are provided in the mark-up. Is there a tag that can be added to get a similar, unique value to be used as the Automation ID? Can I override the Name behavior?
If not, should I read between the lines and determine that UIA is an unacceptable way to perform automation against HTML since it effectively means many controls will not be uniquely identifiable and distinguishable from other controls? That doesn't make any sense to me since some controls map just fine (eg - a Button using where Name = Value property) and can be automated against without incident.
Thanks for any help