user2852847
user2852847

Reputation: 23

How to identify an element for dynamically changing element in coded UI

Page Inspect HTML

The numbers keep changing whenever we perform an action. I have tried the following and it still does not work

HtmlControl clickOnObjectivesCatg = new HtmlControl(bw);
            clickOnObjectivesCatg.SearchProperties.Add(HtmlControl.PropertyNames.Id, "accordiongroup-5856-5055-tab", PropertyExpressionOperator.Contains);
            Mouse.Click(clickOnObjectivesCatg);

Upvotes: 0

Views: 101

Answers (1)

Rescis
Rescis

Reputation: 547

Try this:

var control = new HtmlControl(bw);
control.SearchProperties.Add(HtmlControl.PropertyNames.Id, 
    "accordiongroup", 
    PropertyExpressionOperator.Contains);

I think your problem is yours is checking if the control contains the precise ID, whereas you need to be only checking for the sub string if the number changes.

If you want to make this more reliable I would also suggest adding other search properties.

Upvotes: 1

Related Questions