Package com.github.loyada.jdollarx
Class CustomElementProperties
- java.lang.Object
-
- com.github.loyada.jdollarx.CustomElementProperties
-
public final class CustomElementProperties extends Object
Functions to create customElementProperty
, if the property is unsupported out-of-the-box.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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.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.static <T,V>
ElementPropertyhasProperty(BiFunction<T,V,ElementProperty> propertyGen, T t, V v)
static <T> ElementProperty
hasProperty(Function<T,ElementProperty> propertyGen, T t)
Syntactic sugar that allows to define properties of the form:
-
-
-
Method Detail
-
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")));
- Type Parameters:
T
- the type of the parameter the above functions expect- Parameters:
xpathCreator
- function that generates the xpath that represents this attributetoStringCreator
- function that generates the string (text) representation of this attribute- 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")));
- Type Parameters:
T
- the type of the first parameter the above functions expectV
- the type of the second parameter the above functions expect- Parameters:
xpathCreator
- function that generates the xpath that represents this attributetoStringCreator
- function that generates the string (text) representation of this attribute- 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"));
- Type Parameters:
T
- the type of the value to match to- Parameters:
propertyGen
- a function that was generated using createPropertyGenerator()t
- - a parameter the property generator expects- Returns:
- Element property
-
hasProperty
public static <T,V> ElementProperty hasProperty(BiFunction<T,V,ElementProperty> propertyGen, T t, V v)
- Type Parameters:
T
- the type of the first parameter (t)V
- the type of the second parameter (v)- Parameters:
propertyGen
- a function that was generated using createPropertyGenerator()t
- - first parameter the property generator expectsv
- - first parameter the property generator expects- Returns:
- Element property
-
-