Class AppiumDriverLocalService

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public final class AppiumDriverLocalService
    extends org.openqa.selenium.remote.service.DriverService
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.openqa.selenium.remote.service.DriverService

        org.openqa.selenium.remote.service.DriverService.Builder<DS extends org.openqa.selenium.remote.service.DriverService,​B extends org.openqa.selenium.remote.service.DriverService.Builder<?,​?>>
    • Field Summary

      • Fields inherited from class org.openqa.selenium.remote.service.DriverService

        DEFAULT_TIMEOUT
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addLogMessageConsumer​(java.util.function.Consumer<java.lang.String> consumer)
      When a complete log message is available (from server output data), the specified Consumer is invoked with that log message.
      void addOutPutStream​(java.io.OutputStream outputStream)
      Adds other output stream which should accept server output data.
      void addOutPutStreams​(java.util.List<java.io.OutputStream> outputStreams)
      Adds other output streams which should accept server output data.
      void addSlf4jLogMessageConsumer​(java.util.function.BiConsumer<java.lang.String,​Slf4jLogMessageContext> slf4jLogMessageConsumer)
      When a complete log message is available (from server output data) that message is parsed for its slf4j context (logger name, logger level etc.) and the specified BiConsumer is invoked with the log message and slf4j context.
      static AppiumDriverLocalService buildDefaultService()  
      static AppiumDriverLocalService buildService​(AppiumServiceBuilder builder)  
      boolean clearOutPutStreams()
      Remove all existing server output streams.
      void enableDefaultSlf4jLoggingOfOutputData()
      Enables server output data logging through SLF4J loggers.
      java.lang.String getStdOut()
      Logs as string.
      java.net.URL getUrl()
      Base URL.
      boolean isRunning()  
      void start()
      Starts the defined appium server.
      void stop()
      Stops this service is it is currently running.
      • Methods inherited from class org.openqa.selenium.remote.service.DriverService

        checkExecutable, close, findExecutable, getArgs, getEnvironment, getOutputStream, getTimeout, getUrl, hasShutdownEndpoint, sendOutputTo, waitUntilAvailable
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getUrl

        public java.net.URL getUrl()
        Base URL.
        Overrides:
        getUrl in class org.openqa.selenium.remote.service.DriverService
        Returns:
        The base URL for the managed appium server.
      • isRunning

        public boolean isRunning()
        Overrides:
        isRunning in class org.openqa.selenium.remote.service.DriverService
      • stop

        public void stop()
        Stops this service is it is currently running. This method will attempt to block until the server has been fully shutdown.
        Overrides:
        stop in class org.openqa.selenium.remote.service.DriverService
        See Also:
        start()
      • getStdOut

        @Nullable
        public java.lang.String getStdOut()
        Logs as string.
        Returns:
        String logs if the server has been run. Null is returned otherwise.
      • addOutPutStream

        public void addOutPutStream​(java.io.OutputStream outputStream)
        Adds other output stream which should accept server output data.
        Parameters:
        outputStream - is an instance of OutputStream that is ready to accept server output
      • addOutPutStreams

        public void addOutPutStreams​(java.util.List<java.io.OutputStream> outputStreams)
        Adds other output streams which should accept server output data.
        Parameters:
        outputStreams - is a list of additional OutputStream that are ready to accept server output
      • clearOutPutStreams

        public boolean clearOutPutStreams()
        Remove all existing server output streams.
        Returns:
        true if at least one output stream has been cleared
      • enableDefaultSlf4jLoggingOfOutputData

        public void enableDefaultSlf4jLoggingOfOutputData()
        Enables server output data logging through SLF4J loggers. This allow server output data to be configured with your preferred logging frameworks (e.g. java.util.logging, logback, log4j).

        NOTE1: You might want to call method clearOutPutStreams() before calling this method.
        NOTE2: it is required that --log-timestamp server flag is false.

        By default log messages are:

        • logged at INFO level, unless log message is pre-fixed by [debug] then logged at DEBUG level.
        • logged by a SLF4J logger instance with a name corresponding to the appium sub module as prefixed in log message (logger name is transformed to lower case, no spaces and prefixed with "appium.service.").
        Example log-message: "[ADB] Cannot read version codes of " is logged by logger: appium.service.adb at level INFO.
        Example log-message: "[debug] [XCUITest] Xcode version set to 'x.y.z' " is logged by logger appium.service.xcuitest at level DEBUG.
        See Also:
        addSlf4jLogMessageConsumer(BiConsumer)
      • addSlf4jLogMessageConsumer

        public void addSlf4jLogMessageConsumer​(java.util.function.BiConsumer<java.lang.String,​Slf4jLogMessageContext> slf4jLogMessageConsumer)
        When a complete log message is available (from server output data) that message is parsed for its slf4j context (logger name, logger level etc.) and the specified BiConsumer is invoked with the log message and slf4j context.

        Use this method only if you want a behavior that differentiates from the default behavior as enabled by method enableDefaultSlf4jLoggingOfOutputData().

        NOTE: You might want to call method clearOutPutStreams() before calling this method.

        implementation detail:

        • if log message begins with [debug] then log level is set to DEBUG, otherwise log level is INFO.
        • the appium sub module name is parsed from the log message and used as logger name (prefixed with "appium.service.", all lower case, spaces removed). If no appium sub module is detected then "appium.service" is used as logger name.
        Example log-message: "[ADB] Cannot read version codes of " is logged by appium.service.adb at level INFO
        Example log-message: "[debug] [XCUITest] Xcode version set to 'x.y.z' " is logged by appium.service.xcuitest at level DEBUG
        Parameters:
        slf4jLogMessageConsumer - BiConsumer block to be executed when a log message is available.
      • addLogMessageConsumer

        public void addLogMessageConsumer​(java.util.function.Consumer<java.lang.String> consumer)
        When a complete log message is available (from server output data), the specified Consumer is invoked with that log message.

        NOTE: You might want to call method clearOutPutStreams() before calling this method.

        If the Consumer fails and throws an exception the exception is logged (at WARN level) and execution continues.

        Parameters:
        consumer - Consumer block to be executed when a log message is available.