public final class CustomElementProperties extends Object
ElementProperty, if the property is unsupported out-of-the-box.| Modifier and Type | Method and 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> ElementProperty |
hasProperty(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:
|
public static <T> Function<T,ElementProperty> createPropertyGenerator(Function<T,String> xpathCreator, Function<T,String> toStringCreator)
Function<String, ElementProperty> dataFoo = createPropertyFunc(
fooVal -> String.format("[@data-foo=%s]", fooVal),
fooVal -> "has Foo " + fooVal );
Path myDataEl = element.that(hasProperty(dataFoo("bar")));
T - the type of the parameter the above functions expectxpathCreator - function that generates the xpath that represents this attributetoStringCreator - function that generates the string (text) representation of this attributehasProperty(Function, Object)public static <T,V> BiFunction<T,V,ElementProperty> createPropertyGenerator(BiFunction<T,V,String> xpathCreator, BiFunction<T,V,String> toStringCreator)
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")));
T - the type of the first parameter the above functions expectV - the type of the second parameter the above functions expectxpathCreator - function that generates the xpath that represents this attributetoStringCreator - function that generates the string (text) representation of this attributehasProperty(BiFunction, Object, Object)public static <T> ElementProperty hasProperty(Function<T,ElementProperty> propertyGen, T t)
role = createPropertyGenerator(....);
element.that(hasProperty(role, "foo"));
T - the type of the value to match topropertyGen - a function that was generated using createPropertyGenerator()t - - a parameter the property generator expectspublic static <T,V> ElementProperty hasProperty(BiFunction<T,V,ElementProperty> propertyGen, T t, V v)
T - the type of the first parameter (t)V - the type of the second parameter (v)propertyGen - a function that was generated using createPropertyGenerator()t - - first parameter the property generator expectsv - - first parameter the property generator expectsCopyright © 2018. All rights reserved.