Skip to end of metadata
Go to start of metadata

Locator

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.

Element Locator

Separated by location strategies to following types:

  • JQuery implements Iterable, Compoundable
  • XPath  implements Iterable, Compoundable
  • CSS implements Compoundable
  • ID
  • DOM
  • Link
  • Name
  • Identifier (ID or name)

Iterable Locator

Iterable locator means that you can refer to list of its children (Iterable<ElementLocator>).


Compoundable Locator

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!

Note: it is not case of WebDriver / Selenium 2.0 location strategy - this framework uses the direct references to elements, so you can use each element again to derive new element by referring to it, using whatever location strategy you want - but this is quite problematic in testing AJAX-based frameworks, since the reference can quickly became stale after interaction with page.

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.

Attribute Locator

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: 

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.