CustomElementProperties¶
-
public final class
CustomElementProperties
¶ Functions to create custom
ElementProperty
, if the property is unsupported out-of-the-box.
Methods¶
createPropertyGenerator¶
-
public static <T> Function<T, ElementProperty>
createPropertyGenerator
(Function<T, String> xpathCreator, Function<T, String> toStringCreator)¶ Easy way to define a custom property generator that accepts a single parameter. For example:
Function<String, ElementProperty> dataFoo = createPropertyFunc( fooVal -> String.format("[@data-foo=%s]", fooVal), fooVal -> "has Foo " + fooVal ); Path myDataEl = element.that(hasProperty(dataFoo("bar")));
Parameters: - xpathCreator – function that generates the xpath that represents this attribute
- toStringCreator – function that generates the string (text) representation of this attribute
- <T> – the type of the parameter the above functions expect
Returns: a function that generates an ElementProperty. Use with
hasProperty(Function,Object)
createPropertyGenerator¶
-
public static <T, V> BiFunction<T, V, ElementProperty>
createPropertyGenerator
(BiFunction<T, V, String> xpathCreator, BiFunction<T, V, String> toStringCreator)¶ Easy way to define a custom property generator that accepts two parameter. For example:
Function<String, ElementProperty> dataAttr = createPropertyFunc( (attr, val) -> String.format("[@data-%s=%s]", attr, val), (attr, val) -> String.format("has data-%s of %s", attr, val ); Path myDataEl = element.that(hasProperty(dataAttr("foo", "bar")));
Parameters: - xpathCreator – function that generates the xpath that represents this attribute
- toStringCreator – function that generates the string (text) representation of this attribute
- <T> – the type of the first parameter the above functions expect
- <V> – the type of the second parameter the above functions expect
Returns: a function that generates an ElementProperty. Use with
hasProperty(BiFunction,Object,Object)
hasProperty¶
-
public static <T> ElementProperty
hasProperty
(Function<T, ElementProperty> propertyGen, T t)¶ Syntactic sugar that allows to define properties of the form:
role = createPropertyGenerator(....); element.that(hasProperty(role, "foo"));
Parameters: - propertyGen – a function that was generated using createPropertyGenerator()
- t –
- a parameter the property generator expects
- <T> – the type of the value to match to
Returns: Element property
hasProperty¶
-
public static <T, V> ElementProperty
hasProperty
(BiFunction<T, V, ElementProperty> propertyGen, T t, V v)¶ Parameters: - propertyGen – a function that was generated using createPropertyGenerator()
- t –
- first parameter the property generator expects
- v –
- first parameter the property generator expects
- <T> – the type of the first parameter (t)
- <V> – the type of the second parameter (v)
Returns: Element property