Sunday, December 18, 2022

How to create custom locator classes in Selenium and a few reasons why you should

Selenium supports many different HTML element locator strategies such as CSS, class, ID, and XPath. Xpath in my opinion is provides you with the most flexibility as it has features such as axes (build-in functions) and conditional operators. It would be hard to find an element you couldn’t capture in a sensible way with Xpath but it all depends on how good you’re with Xpath. So if you’re a test framework developer it makes sense for you to abstract out some of the common XPath templates into new By classes. Apart from reducing the chances of inexperienced test engineers making mistakes with the Xpaths, you can increase the readability of the code and provide means for greater reusability (through mechanisms such as ByChained).


Test Layer


Custom By Locator




No comments:

Post a Comment

What's in my Bag? EDC of a Tester