Steps to find XPath of a button in Google Chrome

Below are the simple steps to find XPath of a button on a web page in Google Chrome.

Let’s try to find the XPath of ‘Subscribe’ button on Gethowstuff.com’s homepage.

Steps to find XPath of button

  1. Open Gethowstuff.com in Google Chrome
  2. Right-Click on Subscribe button and click on Inspect
Showing Inspect button on Chrome web page

3. Right-Click on the highlighted area on the console

4. Go to Copy -> Click on Copy XPath

photo showing 'Copy XPath' on Chrome

That’s it. The XPath of the button is copied. Follow same steps to find XPath of any button on the webpage.

Important Note:

When you paste XPath in Python code, replace double quotes of the id with single quotes. Otherwise, you may get syntax error

Example: //*[@id=”text-2″]/div/form/input[3] to //*[@id=’text-2′]/div/form/input[3]

To know how to use it in a script visit Python selenium script – click a button on web page using xpath

About the Author

SRINI S

A passionate blogger. Love to share solutions and best practices on wordpress hosting, issues and fixes, excel VBA macros and other apps

Leave a Reply

Your email address will not be published. Required fields are marked *