hi I have several elements for which I will use the same code there is a chance to put this in the loop for/foreach ?
Best practices, code snippets for common functionality, examples, and guidelines.
2 posts • Page 1 of 1
In order to loop over objects, you need to have it stored in an iterable object, such as a list. The below example should help you achieve this.
Hope this helps!
Code: Select all
List<Element> myElements = new List<Element>(); myElements.Add(repo.FormRun.ButtonOK); myElements.Add(repo.FormRun.Cancel); myElements.Add(repo.FormRun.ButtonBrowse); foreach (var element in myElements) Validate.AttributeEqual(element, "Class", "Button");