Select Page
Codoid Blog

Selenium 4 – Relative Locator

Being a leading QA Company, we write blogs on all prominent software testing topics and tools using our real-world experience. So stay sharp by subscribing to our Newsletter.

Selenium 4 - Relative Locator - Blog
Listen to this blog

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

driver.get("http://codoid.com");
driver.findElement(withTagName("p").near(By.className("cls1"),120));
  

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.

Comments(0)

Submit a Comment

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

Talk to our Experts

Amazing clients who
trust us


poloatto
ABB
polaris
ooredo
stryker
mobility