Package io.testproject.sdk.internal.rest
Class AgentClient
- java.lang.Object
-
- io.testproject.sdk.internal.rest.AgentClient
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public final class AgentClient extends java.lang.Object implements java.io.Closeable
-
-
Field Summary
Fields Modifier and Type Field Description static int
REPORTS_QUEUE_TIMEOUT
Maximum amount of time to wait in seconds before forcibly terminating the queue.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Implementation ofClosable
interface.ActionExecutionResponse
executeProxy(ActionProxy action, int timeout)
Executes a Action proxy from an Addon installed in an Account.static AgentClient
getClient(java.lang.String token, org.openqa.selenium.Capabilities capabilities)
Creates (or searches for an existing) instance ofAgentClient
using provided token and capabilities.static AgentClient
getClient(java.lang.String token, org.openqa.selenium.Capabilities capabilities, ReportSettings reportSettings)
Creates (or searches for an existing) instance ofAgentClient
using provided token and capabilities.static AgentClient
getClient(java.net.URL remoteAddress, java.lang.String token, org.openqa.selenium.Capabilities capabilities, ReportSettings reportSettings, boolean disableReports)
Creates (or searches for an existing) instance ofAgentClient
using provided remoteAddress, token and capabilities.static AgentClient
getClient(java.net.URL remoteAddress, org.openqa.selenium.Capabilities capabilities)
Creates (or searches for an existing) instance ofAgentClient
using provided remoteAddress and capabilities.static AgentClient
getClient(java.net.URL remoteAddress, org.openqa.selenium.Capabilities capabilities, ReportSettings reportSettings)
Creates (or searches for an existing) instance ofAgentClient
using provided remoteAddress and capabilities.static AgentClient
getClient(org.openqa.selenium.Capabilities capabilities)
Creates (or searches for an existing) instance ofAgentClient
using provided capabilities.static AgentClient
getClient(org.openqa.selenium.Capabilities capabilities, ReportSettings reportSettings)
Creates (or searches for an existing) instance ofAgentClient
using provided capabilities.java.lang.String
getJobName()
Getter forjobName
.java.lang.String
getProjectName()
Getter forprojectName
.ReportSettings
getReportSetting()
AgentSession
getSession()
Getter forsession
field.java.lang.String
getVersion()
Getter forversion
field.static java.lang.String
getVersion(java.net.URL remoteAddress)
Retrieves the version of the target Agent.boolean
reportCommand(org.openqa.selenium.remote.Command command, java.lang.Object result, boolean passed, java.lang.String screenshot)
Reports a driver command execution to the Agent.boolean
reportStep(StepReport report)
Reports a step to the Agent.boolean
reportTest(TestReport report)
Reports a test to the Agent.
-
-
-
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(org.openqa.selenium.Capabilities capabilities) throws AgentConnectException, InvalidTokenException, java.net.MalformedURLException, ObsoleteVersionException
Creates (or searches for an existing) instance ofAgentClient
using provided capabilities.- Parameters:
capabilities
-Capabilities
to be used for creatingAgentClient
or finding a cached one- Returns:
- An instance of an AgentClient class.
- Throws:
AgentConnectException
- if Agent is not responding or responds with an errorInvalidTokenException
- if the token provided is invalidjava.net.MalformedURLException
- if the Agent API base URL provided is malformedObsoleteVersionException
- if the SDK version is incompatible with the Agent
-
getClient
public static AgentClient getClient(org.openqa.selenium.Capabilities capabilities, ReportSettings reportSettings) throws AgentConnectException, InvalidTokenException, java.net.MalformedURLException, ObsoleteVersionException
Creates (or searches for an existing) instance ofAgentClient
using provided capabilities.- Parameters:
capabilities
-Capabilities
to be used for creatingAgentClient
or finding a cached onereportSettings
-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 errorInvalidTokenException
- if the token provided is invalidjava.net.MalformedURLException
- if the Agent API base URL provided is malformedObsoleteVersionException
- if the SDK version is incompatible with the Agent
-
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 ofAgentClient
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 creatingAgentClient
or finding a cached one- Returns:
- An instance of an AgentClient class.
- Throws:
AgentConnectException
- if Agent is not responding or responds with an errorInvalidTokenException
- if the token provided is invalidjava.net.MalformedURLException
- if the Agent API base URL provided is malformedObsoleteVersionException
- 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 ofAgentClient
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 creatingAgentClient
or finding a cached onereportSettings
-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 errorInvalidTokenException
- if the token provided is invalidjava.net.MalformedURLException
- if the Agent API base URL provided is malformedObsoleteVersionException
- 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 ofAgentClient
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 creatingAgentClient
or finding a cached onereportSettings
-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 errorInvalidTokenException
- if the token provided is invalidjava.net.MalformedURLException
- if the Agent API base URL provided is malformedObsoleteVersionException
- 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 ofAgentClient
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 creatingAgentClient
or finding a cached one- Returns:
- An instance of an AgentClient class.
- Throws:
AgentConnectException
- if Agent is not responding or responds with an errorInvalidTokenException
- if the token provided is invalidjava.net.MalformedURLException
- if the Agent API base URL provided is malformedObsoleteVersionException
- 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 ofAgentClient
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 creatingAgentClient
or finding a cached onereportSettings
-ReportSettings
with Project and Job names to reportdisableReports
- 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 errorInvalidTokenException
- if the token provided is invalidjava.net.MalformedURLException
- if the Agent API base URL provided is malformedObsoleteVersionException
- if the SDK version is incompatible with the Agent
-
getVersion
public static java.lang.String getVersion(java.net.URL remoteAddress) throws AgentConnectException, java.net.MalformedURLException
Retrieves the version of the target Agent.- 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.- Returns:
- Agent version.
- Throws:
AgentConnectException
- if Agent is not responding or responds with an errorjava.net.MalformedURLException
- if the Agent API base URL provided is malformed
-
getSession
public AgentSession getSession()
Getter forsession
field.- Returns:
- value of
session
field
-
getVersion
public java.lang.String getVersion()
Getter forversion
field.- Returns:
- value of
version
field
-
getProjectName
public java.lang.String getProjectName()
Getter forprojectName
.- Returns:
- value of
projectName
field
-
getReportSetting
public ReportSettings getReportSetting()
- Returns:
- value of
projectName
andjobName
fields wrapped inReportSettings
-
close
public void close()
Implementation ofClosable
interface. Close all open resources such as the reporting queue and the TCP socket open with the Agent.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
reportCommand
public boolean reportCommand(org.openqa.selenium.remote.Command command, java.lang.Object result, boolean passed, java.lang.String screenshot)
Reports a driver command execution to the Agent.- Parameters:
command
- Command executed by the driver.result
- Command result formatted as Stringpassed
- Boolean flag to indicate command successful execution or failure.screenshot
- Screenshot as base64 string.- 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 theActionProxy
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.
-
-