BP31: Locate elements and controls using the right method
Use the following order: id > name > css > xpath
There can be only one id on the page. Finding element by id is very fast and efficient. There is a low risk that the test would get broken because the author of the page has changed the id. Such things don't happen often.
There can be multiple controls with the same name. But it doesn't happen often. Finding element by name is very fast and efficient. There is a low risk hat the test would get broken because the author of the page has changed the name attribute of the control. Such things don't happen often as the programmers are using names in their code and if they change their front-end code, they would need to change back-end code as well.
Finding element by the css selector is fine until the author of the page changes style, template or slightly tweaks html code of the page. Such change is more likely than the change of id or name attribute.
XPath is fine, but it's complex and hard to read for junior testers. It can also be very fragile when more complex xpath query is used.