Foreach loop

Best practices, code snippets for common functionality, examples, and guidelines.
Posts: 92
Joined: Mon Jan 29, 2018 11:19 am

Foreach loop

Post by yaro2o » Mon Mar 04, 2019 3:26 pm

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 ?

You do not have the required permissions to view the files attached to this post.

User avatar
Posts: 135
Joined: Mon Jul 11, 2016 4:01 pm

Re: Foreach loop

Post by N612 » Mon Mar 04, 2019 10:04 pm

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.

Code: Select all

List<Element> myElements = new List<Element>();

foreach (var element in myElements) 
	Validate.AttributeEqual(element, "Class", "Button");
Hope this helps!