Class CapabilityHelpers

java.lang.Object
io.appium.java_client.internal.CapabilityHelpers

public class CapabilityHelpers extends Object
  • Field Details

  • 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 object
      name - capability name
      expectedType - the expected capability type
      Returns:
      The retrieved capability value or null if the cap either not present has an unexpected type
    • toSafeBoolean

      public static @Nullable Boolean toSafeBoolean(Object value)
      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

      public static @Nullable Integer toInteger(Object value)
      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

      public static @Nullable Long toLong(Object value)
      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

      public static @Nullable Double toDouble(Object value)
      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

      public static @Nullable Duration toDuration(Object value)
      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

      public static @Nullable Duration toDuration(Object value, Function<Long,Duration> converter)
      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

      public static @Nullable URL toUrl(Object value)
      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.