Can we access api in 'version 2.0βs offline mode?
Hi, if by access api you refer to invoke API calls with the restful API addon (HTTP get, post, etc) as part of your test, yes you can. basically downloaded tests will run exactly the same like tests that stored in the cloud, if addons are used the TestProject agent will make sure to download all of the dependencies including addon atutomatcily prior execution. if you are running in the completely isolated environment make sure to download your test as βTest Packageβ , by doing that all of the dependencies will be downloaded and zipped to a single file, that is capable to run completely offline, no agent registration will be required in this case as well.
how to download as "Test Package"
how the API saved test will look like as file
id: DELETED
projectId: DELETED
projectName: 2021
created: 2021-03-17T11:47:01.5576790Z
protocol: 1
tests:
- id: zFnO_SqUzUumhDs-1HIKvg
name: Simple API Test
description: ββ
platform: Web
type: Web
driverType: Chrome
version: 0.1
creationDate: 2021-03-17T09:58:16.0000000
modificationDate: 2021-03-17T11:46:46.0000000
settings:
automationAssistant: true
appId: RcyI-hGzrEaqbX9SPaHBNg
stepSleepTime: 500
stepTimeout: 15000
stepSleepTiming: Before
stepFailureBehaviorType: Abort
stepTakeScreenshotConditionType: Failure
application:
id: RcyI-hGzrEaqbX9SPaHBNg
name: Example web site
url: https://example.testproject.io/
platform: Web
steps:- id: W3D3SGbyv02ffb_yRZF6gg
comments: Navigates the specified URL (Auto-generated)
enabled: true
invertResult: false
order: 1
repeat: 1
type: Action
settings:
sleepTime: -1
timeout: -1
sleepTiming: Inherit
failureBehaviorType: Inherit
takeScreenshotConditionType: Inherit
action:
id: 49c5d8d8-4ba8-42f0-823d-702e6acfb23a
source: System
parameterMaps:- name: url
value: β{{ApplicationURL}}β
direction: Input
conditions:
validations:
contexts:
- name: url
- id: EvVl-3asBE6sEnyhX0SD3g
comments: ββ
enabled: true
invertResult: false
order: 2
repeat: 1
type: Addon
settings:
sleepTime: -1
timeout: -1
sleepTiming: Inherit
failureBehaviorType: Inherit
takeScreenshotConditionType: Inherit
action:
id: DiRlYudmtUGjjOgGCGzRIA
source: Store
addonId: Ujn6E4VbkEa6QU2XChYMyQ
parameterMaps:- name: uri
value: β{{tested_API}}β
direction: Input - name: query
value: β{{Query_Param}}β
direction: Input - name: headers
value: ββ
direction: Input - name: expectedStatus
value: 200
direction: Input - name: jsonPath
value: β{{value_to_extract}}β
direction: Input - name: response
value: ββ
direction: Output - name: status
value: ββ
direction: Output - name: ignoreUntrustedCertificate
value: ββ
direction: Input - name: responseHeaders
value: ββ
direction: Output - name: jsonResponse
value: ββ
direction: Output - name: schemaPath
value: ββ
direction: Input - name: createFile
value: ββ
direction: Input - name: schemaValidationOutputFilePath
value: ββ
direction: Input - name: schemaValidationOutput
value: ββ
direction: Output - name: headerDelimiter
value: ββ
direction: Input
conditions:
validations:
contexts:
parameters:
- name: uri
- name: ApplicationURL
description: Auto generated application URL parameter
value: https://example.testproject.io/
type: Input - name: tested_API
description: ββ
value: https://api.nasa.gov/neo/rest/v1/neo/browse
type: Input - name: Query_Param
description: ββ
value: api_key=DEMO_KEY
type: Input - name: value_to_extract
description: ββ
value: $.near_earth_objects[0].neo_reference_id
type: Input
auxTests:
elements:
projectParameters:
addons:
- id: W3D3SGbyv02ffb_yRZF6gg
- id: DELETED
source: Store
version: 1.5
actions:- id: DiRlYudmtUGjjOgGCGzRIA
name: HTTP GET Request
description: GET {{uri}}?{{query}}
className: io.testproject.addon.restfulapiclient.actions.GetAction
minSdkLevel: 0
minSdkVersion: 0.0.0
sdkGeneration: 1
language: Java
hash: DELETED
- id: DiRlYudmtUGjjOgGCGzRIA
Hi Mark, thank you for you answer. Please could you let me know what would be the url to reach api in offline mode? Is it running on any particular port? To trigger tests on your server I use https://api.testproject.io/v2/projects/...
. Would I need something like localhost:port/api.testproject.io/v2/projects/...
?
the local agent url is http://localhost:8585 , but if you want to run your test in the offline mode why not simply use the CLI tool like this: testproject-agent run MyFirstTest.yaml ?
Awesome thank you Mark. Yes to CLI in the future but this will require rewriting what I have already written so far, so I will need to use api for now.
Would I be able using just CLI tool to check the status of recently run test? I know there is report.html, but all I need is to know if the test is successful or not.
Thank you
Hello @mkulik
For that, you still need to use our REST API, using this endpoint:
https://api.testproject.io/docs/v2/#/Reports/Reports_GetV2ProjectsByProjectIdJobsByJobIdReportsLatest
You will get it in a JSON format where you can validate the result of the test/job, if it has passed or failed.
In the future, we will provide the result of the execution locally in JSON format as well.
thank you @ran.tzur, please could you let me know if there is any timeline for this feature to be released?