Selenium has a search by id and/or name therefore, don’t use XPath such as //input[@id=username] or //input[@name=’postalAddress’] for static elements. Searching by ID and name is faster and easier. To make sure that an element is static you need to refresh the page few times using Ctrl-F5 to make sure the element id or name doesn’t change.
This article is for people who want to use Selenium and need to learn XPath. It is organized in several techniques sections where each has a sample scenario and a sample XPath.