Can we "click" on edit boxes using Microsoft UIAutomation libraries

876 views Asked by At

In my application, we have a webbrowserpageviewer control. when a webpage is opened, user needs to click on some of the editboxes present on the webpage. We are trying to simulate this behvior using UI Automation libraries. Am a bit new to this but I see that we can simulate button clicks using InvokePattern so is there any similar method to simulate editbox clicks?

1

There are 1 answers

0
Shobhit_Geek On

You have two ways as far as i know to edit the text boxes:

1.You can add a text in text box using a pattern provided by UIA. This pattern is called ValuePattern.

In C# you can do this in this way:

ValuePattern vp = element_object.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern;
vp.SetValue(value_to_set);

2.You can get the bounding rectangle of text box using the AutomationElement properties after that you can click within it.

Getting bounding rectangle in c#:

automationelement_object.GetCurrentPropertyValue(AutomationElement.BoundingRectangleProperty)