Selenium 4 – Relative Locator


As an automation testing company, we intent to explore new automation testing tools and its features in our Automation CoE’s R&D Workshop. Today, we would like to share one of the salient features of Selenium 4. Selenium 4 Alpha-3 has released a new feature for finding web elements using Relative Locator. It has the following methods – ‘withTagName’, ‘above’, ‘below’, ‘toLeftOf’, ‘toRightOf’, and ‘near’.

Relative Locator Benefits

1) Using ‘near’ method, you can find element with pixel distance.

2) In responsive testing, you can check whether the web elements are rendered in the expected order.

Snippet

Conclusion

If you are familiar with XPath Axes and CSS Selector, then Relative Locator does not add any value. However, it is too early to comment on this feature. Let’s wait for others’ opinion as well.


Leave a Reply

Your email address will not be published. Required fields are marked *