Q:

How to create a loop that increments a tr by 1 with a max of 100 time using a CssSelector in C#

So basically I have a table of 100 rows on a web page, each row contains a button, I want to write a loop that will increment the tr in the CssSelector by 1 with a max of 100 times.
So far I have an extremely receptive process that works but is very costly.
Example of my code:
driver.FindElement(By.CssSelector("#Main > tbody > tr:nth-child(1) > td:nth-child(2)")).Click();
driver.FindElement(By.CssSelector("#Main > tbody > tr:nth-child(2) > td:nth-child(2)")).Click();
driver.FindElement(By.CssSelector("#Main > tbody > tr:nth-child(3) > td:nth-child(2)")).Click();

to 100...
I would like a loop to do something like this:
driver.FindElement(By.CssSelector("#Main > tbody > tr:nth-child(1)[i++] > td:nth-child(2)")).Click();

A:

Use simple for loop. 
string locator;
for(int i=1; i<=100; i++){
locator = "#Main > tbody > tr:nth-child("+i+") > td:nth-child(2)";
driver.FindElement(By.CssSelector(locator)).click();
}

