Relative path means shortcut path. It goes directly to the element instead of parsing or searching from the root element html.
In our previous post, the absolute path for locating all the paragraph text elements on the page is html > body > p . So the relative path for locating all the paragraph text elements on the page is just p .
Lets Implement the Relative CSS path:
1. Suppose if we want to locate all paragraph text elements on the http://compendiumdev.co.uk/selenium/basic_web_page.html page by using Relative CSS path then follow the below steps.
2. Open http://compendiumdev.co.uk/selenium/basic_web_page.html in the Firefox Browser
3. Click on the 'Firepath' tab, select the CSS option, paste the created Relative CSS path i.e. p into the text box as shown below and click on 'Eval' button:
4. Observe that all the paragraph texts on the page are highlighted as shown below:
So we've used the Relative CSS path p for locating all the paragraph text elements on the page.
Please comment below to feedback or ask questions.
Using # to select an element with a specific id will be explained in the next post.