WebDriver provides a number of locator strategies for accessing elements on a webpage. It's tempting to use complex XPath expressions like
//body/div/div/*[@class="someClass"] or CSS selectors like
#content .wrapper .main. While these might work when you are developing your tests, they will almost certainly break when you make unrelated refactoring changes to your HTML output.
Instead, use sensible semantics for CSS IDs and form element names, and try to restrict yourself to using these semantic identifiers. For example, in Java you could designate elements with
)); or driver.findElement(By.name("someName")); or, in the example of PHP, you could use
$this->byName() . This makes it much less likely that you'll inadvertently break your page by shuffling around some lines of code.