I am new to Selenium. I heard that in real time we will not use xpaths generated by tools..rather we will write our own. So i decided to learn writing xpaths. Can u please suggest how to practice writing xpaths and are there any tools where we can validate our written xpaths over scripts..

3 Answers 3


you have to install firebug + firepath in mozilla firefox

enter image description here

it will also provide you generated xpath

enter image description here

You can also write the created xpath in the text field and press enter and it will validate the xpath .//*[contains(@placeholder,'Enter your email')]

for creating xpath and locator search on google about locator strategies in selenium


On writing xpaths: a great reference website if you like reading documentation.

On validating xpaths: You need to run the tests and validate they're clicking on and finding the correct elements.

If there's a syntax issue with your locator, the test will fail since whatever XML parser Selenium uses in your language will throw an exception if you have a malformed xpath.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.