2

I am using Windows UI Automation for desktop applications. UI Automation seems to be able to find elements in the HTML of embedden WebBrowser controls as well, but I could not find a way to give these elements an Automation ID.

I tried these:

<button id="MyButton" >My Button</button>
<button data-automation-id="MyButton" >My Button</button>
<button AutomationProperties.AutomationID="MyButton" >My Button</button>

but none of them gave my button an AutomationID (the second and third were wild guesses).

I am identifying the AutomationElement under the cursor this way:

public AutomationElement AutomationElementFromCursor()
{
   var pt = Forms.Cursor.Position;
   return AutomationElement.FromPoint( new Point( pt.X, pt.Y ) );
}

which works well, my HTML button gets identified, but no AutomationID whatsoever Of course, I could use the "Name" property instead, but this can break my code whenever the button text is changed.

Heinz Kessler
  • 1,610
  • 11
  • 24

0 Answers0