Tuesday, November 19, 2019

Find xpath Using Inspect Option

Here is a simple example to understand the XPath.



XPath = /Shoe store/Shoe[@Category='Gents']/size

Below example describe how to find XPath of 'Username' field in Gmail Login

Step 01 : Navigate into gmail login page

Step 02: Select  username /email text box

Step 03 : Right click -> Inspect -> Select Elements tab

Step 04 : Ctrl + F

Step 05: Write XPath as below

//Input[@id='identifierId]

XPath Declaration


  • // - double  front slash means within this page
  • input - tag name (Ex: input, img, div....)
  • Id - attribute name
  • 'identifiedId' - Value of the attribute
Further Declaration

  • We can select attribute values as mentioned below
  • src, Aria-label, Id
  • Ex: // button[@aria-label='Create video or post']