Show Table of Content

Screenster Public API

Screenster has a public API available on locally installed servers and private cloud instances. With its help, you can interact with Screenster from your tests. The following API calls are available:

  • Execute a test with custom parameters
  • Force test to fail with a JavaScript command

Executing a test with custom parameters

Preconditions: in order to use custom parameters, a test must be recorded and its parameters should be already extracted. After extraction, the parameter names (e.g. {url1} or {param1}) will be used in this call to pass your custom values (e.g. URL or text entry) to this test during execution.
 
URL: /api/public/script/run?userName=someName&userPassword=pswd&scriptId=1&browserType=chrome&verificationType=content&${param1}=someValue&${param2}=someValue
 
where:
 
userName: your login to Screenster
userPassword: your password
scriptId: a test you wish to execute
verificationType: content | visual | minimal
{param1}, {param2}, .. {paramN}: test parameters
 
Success Response: {“meta”:{“code”:200,”message”:”OK”},”response”:{“runs”:[1234]}}.
 
Error Response: {“meta”:{“code”:400,”message”:”Script id is not specified”,”errDetail”:”scriptId is null”},”response”:{}}
 
Result: this test will be executed with the parameters you have specified in the URL above. The execution run number will be ‘1234’ as displayed in the success response. Original test parameters will not be overridden. This operation can be helpful if you need to execute the same tests with numerous parameter sets, generated automatically.
 
Check current status of the test: /api/public/script/status?scriptId=1&userName=someName&userPassword=pswd
 

Using an API call in a JavaScript command to force a test to fail

Preconditions: a test is recorded and ready to be executed. There is a certain element on the page it is testing, and you have its ID.
 
Inserting JavaScript code with an API call: open your test in Edit mode and click on ‘+’ button on a selected step to add a new step. In the popup which opens, click on the ‘Type’ dropdown and select the ‘Execute JavaScript’ option. An editor will be opened. You can use the following code there, for example:
 
if (document.getElementById(“errorLabel”).innerHTML == ‘error’) {Screenster.failTest();}
 
Replace the “errorLabel” with the necessary ID and save the step. Now you can execute the test.
 
Result: the test will fail if such ID cannot be found on the page. This can be useful if you need to verify presence of a certain element before executing the whole test. You can also try some other IF conditions for sending this API call.
  

Want to try Screenster on the cloud?

Try Online

  

WordPress Image Lightbox Plugin