When writing selenium test cases, you are working with locators all the time.
All the locators are encapsulated as instances of Locator interface, divided into two main groups: ElementLocators and AttributeLocators.
Separated by location strategies to following types:
- JQuery implements Iterable, Compoundable
- XPath implements Iterable, Compoundable
- CSS implements Compoundable
- Identifier (ID or name)
Iterable locator means that you can refer to list of its children (Iterable<ElementLocator>).
Compoundable locator signs that you are able to use original expression and some partial expression to derive new composite expression. That way you can desribe the structure of your tested DOM tree in manner of reusability.
It's obvious that by composing and iterating over locator's descendants you can only use and derive the same type of locator!
You can also see that use of type-safe locators is quite verbose - you can then use the capabilities of Graphene utility class as locator factory.
Creating attribute locators is also very straight forward. When you want to refer to attribute's value, you need some element locator first as the base for deriving locator: