Locators for selenium | xpath locator example | gmail login automation example in java-selenium
Tap on the image to get better visibility:
- XPath = XML Path
- It is a type of query language to identify any element on the web page.
- Writing XPath for complex applications sometimes cumbersome task.
- There are plenty of plug-ins available for chrome to find Xpaths and one such tool is "Chropath" pulg-in.
- Take a look at the below image to find relative XPath for "Email or Phone" text input.
Tap on the image to get better visibility of content
from the above HTML, tagname is input | type is an attribute | value is email
Xpath to locate the "Email or phone" is
Java-selenium identifies the element with the following xpath locator
Watch this ~4 min video tutorial example for automating gmail login process in which use xpath locators for "Email or Phone" or "Password" or "Next" buttons.
java-selenium code to identify gmail login using xpath locators