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 intREPORTS_QUEUE_TIMEOUTMaximum 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 voidclose()Implementation ofClosableinterface.ActionExecutionResponseexecuteProxy(ActionProxy action, int timeout)Executes a Action proxy from an Addon installed in an Account.static AgentClientgetClient(java.lang.String token, org.openqa.selenium.Capabilities capabilities)Creates (or searches for an existing) instance ofAgentClientusing provided token and capabilities.static AgentClientgetClient(java.lang.String token, org.openqa.selenium.Capabilities capabilities, ReportSettings reportSettings)Creates (or searches for an existing) instance ofAgentClientusing provided token and capabilities.static AgentClientgetClient(java.net.URL remoteAddress, java.lang.String token, org.openqa.selenium.Capabilities capabilities, ReportSettings reportSettings, boolean disableReports)Creates (or searches for an existing) instance ofAgentClientusing provided remoteAddress, token and capabilities.static AgentClientgetClient(java.net.URL remoteAddress, org.openqa.selenium.Capabilities capabilities)Creates (or searches for an existing) instance ofAgentClientusing provided remoteAddress and capabilities.static AgentClientgetClient(java.net.URL remoteAddress, org.openqa.selenium.Capabilities capabilities, ReportSettings reportSettings)Creates (or searches for an existing) instance ofAgentClientusing provided remoteAddress and capabilities.static AgentClientgetClient(org.openqa.selenium.Capabilities capabilities)Creates (or searches for an existing) instance ofAgentClientusing provided capabilities.static AgentClientgetClient(org.openqa.selenium.Capabilities capabilities, ReportSettings reportSettings)Creates (or searches for an existing) instance ofAgentClientusing provided capabilities.java.lang.StringgetJobName()Getter forjobName.java.lang.StringgetProjectName()Getter forprojectName.ReportSettingsgetReportSetting()AgentSessiongetSession()Getter forsessionfield.java.lang.StringgetVersion()Getter forversionfield.booleanreportCommand(org.openqa.selenium.remote.Command command, java.lang.Object result, boolean passed, java.lang.String screenshot)Reports a driver command execution to the Agent.booleanreportStep(StepReport report)Reports a step to the Agent.booleanreportTest(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 ofAgentClientusing provided capabilities.- Parameters:
capabilities-Capabilitiesto be used for creatingAgentClientor 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 ofAgentClientusing provided capabilities.- Parameters:
capabilities-Capabilitiesto be used for creatingAgentClientor finding a cached onereportSettings-ReportSettingswith 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 ofAgentClientusing 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-Capabilitiesto be used for creatingAgentClientor 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 ofAgentClientusing 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-Capabilitiesto be used for creatingAgentClientor finding a cached onereportSettings-ReportSettingswith 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 ofAgentClientusing 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-Capabilitiesto be used for creatingAgentClientor finding a cached onereportSettings-ReportSettingswith 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 ofAgentClientusing 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-Capabilitiesto be used for creatingAgentClientor 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 ofAgentClientusing 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-Capabilitiesto be used for creatingAgentClientor finding a cached onereportSettings-ReportSettingswith 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
-
getSession
public AgentSession getSession()
Getter forsessionfield.- Returns:
- value of
sessionfield
-
getVersion
public java.lang.String getVersion()
Getter forversionfield.- Returns:
- value of
versionfield
-
getProjectName
public java.lang.String getProjectName()
Getter forprojectName.- Returns:
- value of
projectNamefield
-
getReportSetting
public ReportSettings getReportSetting()
- Returns:
- value of
projectNameandjobNamefields wrapped inReportSettings
-
close
public void close()
Implementation ofClosableinterface. Close all open resources such as the reporting queue and the TCP socket open with the Agent.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein 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 theActionProxyclass.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.
-
-