I need to get the last element in loop as this is the selector i need to click. Currentyly I got 2 loops - first counts the selectors and second - counts it again and if counter is equal to first counter, then click. This logic works however I don’t like it visualy as it is repeating the same loop I was wondering if there is another way, more elegant? I’’ve heared about Count(). Might be a solution to run the Count() first and then compare it with counter?
Is the loop running over a list or table , if it is a list you can access with negative indexing, if it is a table you can get count of rows the use datatable.Rows(rowcount)(columncount) eg: for first row dt.Rows(0)(0)
Don’t use a loop for this. If you want to click the first item, then use .First, and last item use .Last
You can also use the index, when .First or .Last is not a member of the enumerable.
So, don’t use a loop unless you need to perform actions on multiple items. In your case, you can just go straight to the click and use .First or .Last.