Search code examples
seleniumselenium-webdriverxpathwebdriverxpath-1.0

Xpath type locator for the Login input


I want to understand this but I am kinda confused:

Taking the following login as an example, if we want to identify an xpath type locator for the Login input, what would it be the most appropriate option as a good practice. Note that all of these options work correctly when locating the Login (input) object.

Image:

Image

Can someone help me out?


Solution

  • Among the following suggestions:

    suggestions

    The most canonical locator strategy would be option b:

    //input[@id='user_login']