The most effective method for locating elements on a web page is XPath. It is a query language used to find and choose nodes within an XML document.
In order to pass any company technical tests, you will only be able to find XPath in Chrome browser, so I'll advise you to practice finding it in the The steps below explain how to use the Chrome browser and a Selenium WebDriver script to inspect an element and determine its XPath. These are what they are:
- Launch the Chrome browser and open a URL or website.
- Place the mouse pointer over the desired element (object) on the website and perform a right-click on that element to reveal the "Inspect Element" option.
- The elements panel will now be displayed on the right side of the screen. The element's HTML code will be highlighted in blue in this frame.
- To enable DOM searching in the panel, press Ctrl+F.
- You can now enter XPath to evaluate for that element in the panel.
- If any XPath matches are found, Chrome will open more and more.