One of the articles mentions XPath element positioning, but some of the articles do not fit into special and personalized scenarios. You can find the solution you need here in the text that provides the ultimate placement of XPath elements.
The first method:
Positioning by Absolute path (I'm sure you won't use this way)
By.xpath ("Html/body/div/form/input")
The second method:
By thinking that the other side is positioning
By.xpath ("//input")
The third method:
Positioning by Element Index
By.xpath ("//input[4]")
The fourth method:
Use XPath attribute positioning (combined with 2nd, 3rd method can be used)
By.xpath ("//input[@id = ' kw1 ']")
By.xpath ("//input[@type = ' name ' and @name = ' kw1 ']")
The Fifth method:
Use partial attribute value matching (the most powerful method)
By.xpath ("//input[start-with (@id, ' nice ')
By.xpath ("//input[ends-with (@id, ' very pretty")
By.xpath ("//input[contains (@id, ' so Beautiful ')]")
The 6th method:
Use an XPath axis (not used)
Selenium using XPath to locate the entire article