Although it's sims very logical to find am element by his name, there are few major limitations that you need to know:
· The name attribute may not be unique on a page (the same name can be assigned to multiple elements).
· If you use this attribute and it's assigned to multiple elements, the first element on the page with this name will be returned by the API.
To locate the contact form user name field, we will now use the name attribute:
<input type="text" value="" size="30" name="name" id="ContactForm1_contact-form-name" class="contact-form-name">
public void FindElementByName()
IWebDriver Firefox = new FirefoxDriver();
WebElement = Firefox.FindElement(By.Name("name"));