Class AppiumUserAgentFilter

  • All Implemented Interfaces:
    java.util.function.Function<org.openqa.selenium.remote.http.HttpHandler,​org.openqa.selenium.remote.http.HttpHandler>, org.openqa.selenium.remote.http.Filter

    public class AppiumUserAgentFilter
    extends java.lang.Object
    implements org.openqa.selenium.remote.http.Filter
    Manage Appium Client configurations.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String USER_AGENT
      A default User Agent name for Appium Java client.
      static java.lang.String VERSION_KEY  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.openqa.selenium.remote.http.HttpHandler apply​(org.openqa.selenium.remote.http.HttpHandler next)  
      static java.lang.String buildUserAgent​(java.lang.String userAgent)
      Returns the User Agent.
      static boolean containsAppiumName​(java.lang.String userAgent)
      Returns true if the given User Agent includes "appium/", which implies the User Agent already has the Appium UA by this method.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.openqa.selenium.remote.http.Filter

        andFinally, andFinally, andThen
      • Methods inherited from interface java.util.function.Function

        andThen, compose
    • Field Detail

      • USER_AGENT

        public static final java.lang.String USER_AGENT
        A default User Agent name for Appium Java client. e.g. appium/8.2.0 (selenium/4.5.0 (java mac))
    • Constructor Detail

      • AppiumUserAgentFilter

        public AppiumUserAgentFilter()
    • Method Detail

      • containsAppiumName

        public static boolean containsAppiumName​(@Nullable
                                                 java.lang.String userAgent)
        Returns true if the given User Agent includes "appium/", which implies the User Agent already has the Appium UA by this method. The matching is case-insensitive.
        Parameters:
        userAgent - the User Agent in the request headers.
        Returns:
        whether the given User Agent includes Appium UA like by this filter.
      • buildUserAgent

        public static java.lang.String buildUserAgent​(@Nullable
                                                      java.lang.String userAgent)
        Returns the User Agent. If the given UA already has USER_AGENT_PREFIX, it returns the UA. IF the given UA does not have USER_AGENT_PREFIX, it returns UA with the Appium prefix.
        Parameters:
        userAgent - the User Agent in the request headers.
        Returns:
        the User Agent for the request
      • apply

        public org.openqa.selenium.remote.http.HttpHandler apply​(org.openqa.selenium.remote.http.HttpHandler next)
        Specified by:
        apply in interface java.util.function.Function<org.openqa.selenium.remote.http.HttpHandler,​org.openqa.selenium.remote.http.HttpHandler>