Package io.appium.java_client.internal
Class CapabilityHelpers
java.lang.Object
io.appium.java_client.internal.CapabilityHelpers
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> @Nullable TgetCapability(org.openqa.selenium.Capabilities caps, String name, Class<T> expectedType) Helper that is used for capability values retrieval.static @Nullable DoubleConverts generic capability value to double.static @Nullable DurationtoDuration(Object value) Converts generic capability value to duration.static @Nullable DurationtoDuration(Object value, Function<Long, Duration> converter) Converts generic capability value to duration.static @Nullable IntegerConverts generic capability value to integer.static @Nullable LongConverts generic capability value to long.static @Nullable BooleantoSafeBoolean(Object value) Converts generic capability value to boolean without throwing exceptions.static @Nullable URLConverts generic capability value to a url.
-
Field Details
-
APPIUM_PREFIX
- See Also:
-
-
Method Details
-
getCapability
public static <T> @Nullable T getCapability(org.openqa.selenium.Capabilities caps, String name, Class<T> expectedType) Helper that is used for capability values retrieval. Supports both prefixed W3C and "classic" capability names.- Type Parameters:
T- The corresponding capability type.- Parameters:
caps- driver caps objectname- capability nameexpectedType- the expected capability type- Returns:
- The retrieved capability value or null if the cap either not present has an unexpected type
-
toSafeBoolean
Converts generic capability value to boolean without throwing exceptions.- Parameters:
value- The capability value.- Returns:
- null is the passed value is null otherwise the converted value.
-
toInteger
Converts generic capability value to integer.- Parameters:
value- The capability value.- Returns:
- null is the passed value is null otherwise the converted value.
- Throws:
NumberFormatException- If the given value cannot be parsed to a valid integer.
-
toLong
Converts generic capability value to long.- Parameters:
value- The capability value.- Returns:
- null is the passed value is null otherwise the converted value.
- Throws:
NumberFormatException- If the given value cannot be parsed to a valid long.
-
toDouble
Converts generic capability value to double.- Parameters:
value- The capability value.- Returns:
- null is the passed value is null otherwise the converted value.
- Throws:
NumberFormatException- If the given value cannot be parsed to a valid long.
-
toDuration
Converts generic capability value to duration. The value is assumed to be measured in milliseconds.- Parameters:
value- The capability value.- Returns:
- null is the passed value is null otherwise the converted value.
- Throws:
NumberFormatException- If the given value cannot be parsed to a valid number.
-
toDuration
Converts generic capability value to duration.- Parameters:
value- The capability value.converter- Converts the numeric value to a Duration instance.- Returns:
- null is the passed value is null otherwise the converted value.
- Throws:
NumberFormatException- If the given value cannot be parsed to a valid number.
-
toUrl
Converts generic capability value to a url.- Parameters:
value- The capability value.- Returns:
- null is the passed value is null otherwise the converted value.
- Throws:
IllegalArgumentException- If the given value cannot be parsed to a valid url.
-