• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • Home
  • Programming Languages
    • Java Tutorials
    • Python Tutorials
    • JavaScript Tutorials
  • Automation Tools and Different Tools
    • Web Automation
      • Selenium with Java
        • Selenium Basic
        • Selenium Advance
        • Selenium Realtime
        • Framework
        • Selenium Interview
        • Selenium Videos
        • Selenium with Docker
      • Selenium with Python
      • WebdriverIO
        • Selenium Webdriver C# Tutorial
      • Cypress
      • Playwright
    • TestNG
    • Cucumber
    • Mobile Automation
      • Appium
    • API Testing
      • Postman
      • Rest Assured
      • SOAPUI
    • testRigor
    • Katalon
    • TestProject
    • Serenity BDD
    • Gradle- Build Tool
    • RPA-UiPath
    • Protractor
    • Windows Automation
  • Automation For Manual Testers
  • Services
  • Online Training
  • Contact us
  • About me
  • Follow us
    • Linkedin
    • Facebook Group
    • Facebook Page
    • Instagram

Automation

Selenium WebDriver tutorial Step by Step

You are here: Home / Basic Selenium / How to find xpath in Chrome browser and Write for Selenium

How to find xpath in Chrome browser and Write for Selenium

November 1, 2017 by Mukesh Otwani 15 Comments

Welcome to Selenium tutorial, in this post, we will see how to find xpath in Chrome browser for Selenium script development.

Till now we have seen that we have so many plugins for xpath in Firefox Browser like Firebug and Firepath but for Chrome, IE and another browser we do not have a plugin to identify xpath.

In the last post,we have seen Awesome plugin in Firefox for xpath and  if you still have not used then please give a try. 🙂

Today I was googling something and found one good post for Xpath in chrome browser and I installed the same on my machine and it worked easily so thought of sharing with all.

This plugin will not generate xpath like firebug and other plugin do but yes, you can verify your xpath at least.

Find xpath in Chrome browser

Install Xpath Helper plugin for Chrome.

1- Open below URL and Click on Add to Chrome button.

Xpath Helper- https://chrome.google.com/webstore/detail/xpath-helper/hgimnogjllphhhkhlmebbmlgjoejdpjl?hl=en

Xpath plugin in Chrome browser

 

Step 2- Once plugin added to Chrome. Open your application and press SHIFT+CTRL+X. Black window will appear on top then you can play with xpath. Refer below screenshot for more details.

 

find xpath in Chrome browser

 

On the top left page, you can write xpath and the right-hand side you can check the result. If single result found then it will show result 1 and if it matches with multiple items then it will show you count as well.

If xpath is invalid- then you will get xpath error and if no matches found then it will display NULL.

Note- To check element attribute still you can use F12 that is nothing but default inspect element for all browser then check attribute and create your own xpath and try.

 

Xpath Syntax

// tagname[@attribute-name=’value1′]  and if you are not sure about tag name then no worry you can try with * also

// *[@attribute-name=’value1′]

 

 

Thanks for visiting my blog. If you find this post informative then please share with your friends.

For more updates like our Facebook Page.

For any Selenium related query Join Facebook Group.

 

Filed Under: Basic Selenium Tagged With: Chrome Xpath Plugin

Reader Interactions

Comments

  1. lakshmi says

    May 22, 2019 at 10:26 AM

    Hi mukesh, can u pls tell me how to write xpathusing href

    Reply
    • Mukesh Otwani says

      May 22, 2019 at 2:41 PM

      Hi Lakshmi,

      Same way you do for any other attributes like //a[@herf=’value_of_href_available_in_DOM’]

      Reply
  2. Harshitha says

    December 31, 2017 at 12:23 AM

    If I take gmail in that new user registration form and login form will be der. So can I write those two in one script?
    If it s pls let me know the code

    Reply
    • Mukesh Otwani says

      January 1, 2018 at 11:02 PM

      Hi Harshitha,

      It depends on how you much granularity you require for functionality test and what is your business requirement. If you are using testng then either you can define both of these functionality under different @Test annotations in same script or you can make different scripts for same. Another thing, how you will execute these scripts, I mean using some application like Jenkins or Bamboo or so on.

      Reply
  3. Mahul says

    February 16, 2017 at 11:38 PM

    Thanks Mukesh Sir,
    There is one xpath helper for chrome browser i.e. Relative Xpath Helper.
    This will be added as a extension in chrome.
    We are using this extension to find the xpath on chrome browser and its very helpful.

    Reply
    • Mukesh Otwani says

      February 17, 2017 at 9:03 AM

      Hi Mahul,

      I am happy to see my blog post has helped you.

      Reply
  4. Nikhil says

    September 24, 2016 at 10:57 PM

    Mukesh even I tried tool, but it took time to adjust, but compared to firepath its difficult to find Xpath on chrome, any idea.

    Reply
    • Mukesh Otwani says

      September 29, 2016 at 11:12 AM

      No updates on this.

      Reply
  5. Ranjith samalla says

    July 18, 2016 at 12:07 PM

    Hi Mukesh,

    Good Morning, Today i tried xpath for chrome but when I’m clicking on ctl+shift+x or i’m selecting through icon but how can we generet xpath still i’m gettiing confuse can u xpln clrly or els can u make video 4r this,

    Reply
    • Mukesh Otwani says

      July 20, 2016 at 2:01 PM

      Seems this plugin is outdated.

      Reply
    • Phani says

      September 19, 2016 at 9:53 AM

      Ranjith, Here you can check if your xpath is correct or not in this tool. You can even see the if multiple items matches. I would say this extension is great checking tool rather generating tool. Some one please correct me if I’m wrong.
      Thanks.

      Reply
      • Gaurav Khurana says

        November 3, 2016 at 10:22 PM

        Yes i agree. this is a nice tool for testing xpath.

        Xpath can be generated by pressing the shift button and selecting the item. But the xpath generated is the absolute and is not very friendly.

        Thanks Mukesh..

        i have found one of the best way on stackoverflow

        up vote
        5
        down vote
        Let tell you a simple formula to find xpath of any element:

        1- Open site in browser

        2- Select element and right click on it

        3- Click inspect element option

        4- Right click on selected html

        5- choose option to copy xpath Use it where ever you need it

        you can include this … its simple and awesome

        Reply
        • Mukesh Otwani says

          November 4, 2016 at 12:32 AM

          Thanks Gaurav

          Reply
        • Komal says

          November 28, 2016 at 1:17 PM

          Thanks Gaurav for such useful information.
          Really helpful.:)

          Reply
          • Mukesh Otwani says

            November 28, 2016 at 11:35 PM

            Thanks Komal 🙂 Keep visiting.

Leave a Reply Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Free Selenium Videos

https://www.youtube.com/watch?v=w_iPCT1ETO4

Search topic

Top Posts & Pages

  • Selenium Webdriver tutorial for beginners
  • How To Fix Eclipse Autocomplete Or Code Suggestion In Eclipse
  • Selenium Webdriver C# Tutorial
  • WHAT ARE YOUR EXPECTATIONS FROM US?

Stay connected via Facebook

Stay connected via Facebook

Archives

Footer

Categories

Recent Post

  • API Testing Using Postman And RestAssured
  • Disable Personalise Your Web Experience Microsoft Edge Prompt In Selenium
  • How To Fix Error: No tests found In Playwright
  • How To Fix Eclipse Autocomplete Or Code Suggestion In Eclipse
  • Best and easy way to Group test cases in selenium

Top Posts & Pages

  • Selenium Webdriver tutorial for beginners
  • How To Fix Eclipse Autocomplete Or Code Suggestion In Eclipse
  • Selenium Webdriver C# Tutorial
  • WHAT ARE YOUR EXPECTATIONS FROM US?