Class AgentClient

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

    public final class AgentClient
    extends java.lang.Object
    implements java.io.Closeable
    • Field Detail

      • REPORTS_QUEUE_TIMEOUT

        public static final int REPORTS_QUEUE_TIMEOUT
        Maximum amount of time to wait in seconds before forcibly terminating the queue.
        See Also:
        Constant Field Values
    • Method Detail

      • getClient

        public static AgentClient getClient​(java.lang.String token,
                                            org.openqa.selenium.Capabilities capabilities)
                                     throws AgentConnectException,
                                            InvalidTokenException,
                                            java.net.MalformedURLException,
                                            ObsoleteVersionException
        Creates (or searches for an existing) instance of AgentClient using provided token and capabilities.
        Parameters:
        token - Development token, required to initialize a session with the Agent. If not provided, will attempt to get the value from TP_DEV_TOKEN environment variable.
        It can be obtained from SDK page.
        capabilities - Capabilities to be used for creating AgentClient or finding a cached one
        Returns:
        An instance of an AgentClient class.
        Throws:
        AgentConnectException - if Agent is not responding or responds with an error
        InvalidTokenException - if the token provided is invalid
        java.net.MalformedURLException - if the Agent API base URL provided is malformed
        ObsoleteVersionException - if the SDK version is incompatible with the Agent
      • getClient

        public static AgentClient getClient​(java.lang.String token,
                                            org.openqa.selenium.Capabilities capabilities,
                                            ReportSettings reportSettings)
                                     throws AgentConnectException,
                                            InvalidTokenException,
                                            java.net.MalformedURLException,
                                            ObsoleteVersionException
        Creates (or searches for an existing) instance of AgentClient using provided token and capabilities.
        Parameters:
        token - Development token, required to initialize a session with the Agent. If not provided, will attempt to get the value from TP_DEV_TOKEN environment variable.
        It can be obtained from SDK page.
        capabilities - Capabilities to be used for creating AgentClient or finding a cached one
        reportSettings - ReportSettings with Project and Job names to report
        Returns:
        An instance of an AgentClient class.
        Throws:
        AgentConnectException - if Agent is not responding or responds with an error
        InvalidTokenException - if the token provided is invalid
        java.net.MalformedURLException - if the Agent API base URL provided is malformed
        ObsoleteVersionException - if the SDK version is incompatible with the Agent
      • getClient

        public static AgentClient getClient​(java.net.URL remoteAddress,
                                            org.openqa.selenium.Capabilities capabilities,
                                            ReportSettings reportSettings)
                                     throws AgentConnectException,
                                            InvalidTokenException,
                                            java.net.MalformedURLException,
                                            ObsoleteVersionException
        Creates (or searches for an existing) instance of AgentClient using provided remoteAddress and capabilities.
        Parameters:
        remoteAddress - Agent API base URL
        If not provided, will attempt to get the value from TP_AGENT_URL environment variable.
        If the environment variable is not set, default URL http://localhost:8585 is used.
        capabilities - Capabilities to be used for creating AgentClient or finding a cached one
        reportSettings - ReportSettings with Project and Job names to report
        Returns:
        An instance of an AgentClient class.
        Throws:
        AgentConnectException - if Agent is not responding or responds with an error
        InvalidTokenException - if the token provided is invalid
        java.net.MalformedURLException - if the Agent API base URL provided is malformed
        ObsoleteVersionException - if the SDK version is incompatible with the Agent
      • getClient

        public static AgentClient getClient​(java.net.URL remoteAddress,
                                            org.openqa.selenium.Capabilities capabilities)
                                     throws AgentConnectException,
                                            InvalidTokenException,
                                            java.net.MalformedURLException,
                                            ObsoleteVersionException
        Creates (or searches for an existing) instance of AgentClient using provided remoteAddress and capabilities.
        Parameters:
        remoteAddress - Agent API base URL
        If not provided, will attempt to get the value from TP_AGENT_URL environment variable.
        If the environment variable is not set, default URL http://localhost:8585 is used.
        capabilities - Capabilities to be used for creating AgentClient or finding a cached one
        Returns:
        An instance of an AgentClient class.
        Throws:
        AgentConnectException - if Agent is not responding or responds with an error
        InvalidTokenException - if the token provided is invalid
        java.net.MalformedURLException - if the Agent API base URL provided is malformed
        ObsoleteVersionException - if the SDK version is incompatible with the Agent
      • getClient

        public static AgentClient getClient​(java.net.URL remoteAddress,
                                            java.lang.String token,
                                            org.openqa.selenium.Capabilities capabilities,
                                            ReportSettings reportSettings,
                                            boolean disableReports)
                                     throws AgentConnectException,
                                            InvalidTokenException,
                                            java.net.MalformedURLException,
                                            ObsoleteVersionException
        Creates (or searches for an existing) instance of AgentClient using provided remoteAddress, token and capabilities.
        Parameters:
        remoteAddress - Agent API base URL
        If not provided, will attempt to get the value from TP_AGENT_URL environment variable.
        If the environment variable is not set, default URL http://localhost:8585 is used.
        token - Development token, required to initialize a session with the Agent. If not provided, will attempt to get the value from TP_DEV_TOKEN environment variable.
        It can be obtained from SDK page.
        capabilities - Capabilities to be used for creating AgentClient or finding a cached one
        reportSettings - ReportSettings with Project and Job names to report
        disableReports - True to disable automatic reporting of driver commands and tests, otherwise False.
        Returns:
        An instance of an AgentClient class.
        Throws:
        AgentConnectException - if Agent is not responding or responds with an error
        InvalidTokenException - if the token provided is invalid
        java.net.MalformedURLException - if the Agent API base URL provided is malformed
        ObsoleteVersionException - if the SDK version is incompatible with the Agent
      • removeClient

        public static void removeClient​(org.openqa.selenium.Capabilities capabilities)
        Removed cached client and closes it.
        Parameters:
        capabilities - capabilities with custom TestProject tracking capability
      • getProjectName

        public java.lang.String getProjectName()
        Getter for projectName.
        Returns:
        value of projectName field
      • getJobName

        public java.lang.String getJobName()
        Getter for jobName.
        Returns:
        value of jobName field
      • close

        public void close()
        Implementation of Closable interface. Disconnects the TCP socket between the SDK and the Agent to stop the development session.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
      • reportCommand

        public boolean reportCommand​(org.openqa.selenium.remote.Command command,
                                     java.lang.Object result,
                                     boolean passed)
        Reports a driver command execution to the Agent.
        Parameters:
        command - Command executed by the driver.
        result - Command result formatted as String
        passed - Boolean flag to indicate command successful execution or failure.
        Returns:
        True if successfully reported, otherwise False.
      • reportStep

        public boolean reportStep​(StepReport report)
        Reports a step to the Agent.
        Parameters:
        report - Report to submit.
        Returns:
        True is successful, otherwise False.
      • reportTest

        public boolean reportTest​(TestReport report)
        Reports a test to the Agent.
        Parameters:
        report - Report to submit.
        Returns:
        True is successful, otherwise False.
      • executeProxy

        public ActionExecutionResponse executeProxy​(ActionProxy action,
                                                    int timeout)
                                             throws org.openqa.selenium.WebDriverException
        Executes a Action proxy from an Addon installed in an Account.
        Parameters:
        action - An instance of an action that extends the ActionProxy class.
        timeout - maximum amount of time allowed to wait for action execution to complete.
        Returns:
        Execution result in form of ActionExecutionResponse.
        Throws:
        org.openqa.selenium.WebDriverException - when execution fails.