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
you have to install firebug + firepath in mozilla firefox
it will also provide you generated xpath
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.