Please help me on this am trying to locate the element using xpath
Here's one way to locate the Xpath or CSS Selector for a given web element:
- Using Chrome, open Developer Tools. You can also right-click on web element and select "Inspect"
- Select Elements tab
- Locate web element using right-click, Inspect or use the arrow icon near the Element tabs to select the web element. Either way, the web element will be highlighted in the Elements pane.
- With the element highlighted in Elements pane, right click on it and go to "Copy > Copy Xpath". Alternatively, you can select "Copy > Copy Selector". This will copy the correct Xpath or CSS Selector to your clipboard.
Note: Keep in mind, Xpath is slow and a brittle way of locating elements in Selenium as it is dependent on an exact path in the DOM. If the UI changes, the Xpath will most likely break. You'll spend a lot more time in maintenance fixing your Xpaths. Instead, use CSS Selectors, IDs, Names for faster element location. These are also more direct way of finding the correct element in Selenium and is less likely to fail when the app/UI changes.