API Documentation

Test Resource

Search our documentation:

Toggle Documentation Menu

API: Test Resource

Jump to...


List Tests

Fetch an array of all the tests in your account.

Request
GEThttps://api.ghostinspector.com/v1/tests/?apiKey=<apiKey>
Parameters
apiKey
Your API key provided in your account
Response
{
  "code": "SUCCESS",
  "data": [
    {
      "_id": "53323248ca5ec57161cf2637",
      "dateExecutionFinished": "2014-04-18T01:17:55.617Z",
      "dateExecutionStarted": "2014-04-18T01:17:27.569Z",
      "startUrl": "http://www.sampledomain1.com/",
      "suite": {
        "_id": "5330e25967076985585532fb",
        "name": "Suite Name"
      },
      "organization": {
        "_id": "52df0d27fbaced54db000006",
        "name": "Organization Name"
      },
      "dateCreated": "2014-03-26T01:50:00.968Z",
      "notifications": 0,
      "screenshotComparePassing": null,
      "screenshotCompareThreshold": 0.2,
      "screenshotCompareEnabled": false,
      "passing": false,
      "viewportSize": {
        "height": 768,
        "width": 1024
      },
      "testFrequency": 0,
      "name": "Test #1"
    },
    {
      "_id": "533232a2ca5ec57161cf263f",
      "dateExecutionFinished": "2014-04-18T01:22:30.420Z",
      "dateExecutionStarted": "2014-04-18T01:22:13.400Z",
      "startUrl": "http://www.sampledomain2.com/",
      "suite": {
        "_id": "5330e25967076985585532fb",
        "name": "Suite Name"
      },
      "organization": {
        "_id": "52df0d27fbaced54db000006",
        "name": "Organization Name"
      },
      "dateCreated": "2014-03-26T01:51:30.443Z",
      "notifications": 0,z
      "screenshotComparePassing": true,
      "screenshotCompareThreshold": 0.2,
      "screenshotCompareEnabled": true,
      "passing": true,
      "viewportSize": {
        "height": 768,
        "width": 1024
      },
      "testFrequency": 0,
      "name": "Test #2"
    }
  ]
}


Get Test

Fetch a single test

Request
GEThttps://api.ghostinspector.com/v1/tests/<testId>/?apiKey=<apiKey>
Parameters
apiKey
Your API key provided in your account
testId
The ID of the test to fetch
Response
{
  "code": "SUCCESS",
  "data": {
    "_id": "5335c6a5f6d88b3069f1ac06",
    "dateExecutionFinished": "2014-04-18T17:52:27.588Z",
    "dateExecutionStarted": "2014-04-18T17:52:17.305Z",
    "startUrl": "https://www.google.com/",
    "suite": {
      "_id": "5330e25967076985585532fb",
      "name": "Suite Name"
    },
    "organization": {
      "_id": "52df0d27fbaced54db000006",
      "name": "Organization Name"
    },
    "dateCreated": "2014-03-28T18:59:49.027Z",
    "notifications": 0,
    "screenshotComparePassing": false,
    "screenshotCompareThreshold": 0.2,
    "screenshotCompareEnabled": false,
    "passing": true,
    "steps": [
      {
        "_id": "5335c6a5f6d88b3069f1ac09",
        "command": "click",
        "target": "#gbqfq",
        "private": false,
        "sequence": 0
      },
      {
        "_id": "5335c6a5f6d88b3069f1ac08",
        "command": "assign",
        "target": "#gbqfq",
        "value": "ghosts",
        "private": false,
        "sequence": 1
      },
      {
        "_id": "5335c6a5f6d88b3069f1ac07",
        "command": "keypress",
        "target": "#gbqfq",
        "value": "13",
        "private": false,
        "sequence": 2
      },
      {
        "_id": "5351650c4f827814f0930434",
        "command": "assertElementPresent",
        "target": "h3",
        "value": "",
        "private": false,
        "sequence": 3
      }
    ],
    "viewportSize": {
      "height": 768,
      "width": 1024
    },
    "testFrequency": 0,
    "name": "Google #1"
  }
}


Execute Test

Execute a single test in your account and return the result.

Note: Test are executed in real time so this request can take some time to return. We’d suggest programming your request to deal with response times of up to 11 minutes. Tests are currently limited to 10 minutes of run time.
Request
GEThttps://api.ghostinspector.com/v1/tests/<testId>/execute/?apiKey=<apiKey>&startUrl=<startUrl>
Parameters
apiKey
Your API key provided in your account
testId
The ID of the test to execute
startUrl
(Optional) Alternate start URL to use for this execution only
viewport
(Optional) Alternate screen size to use for this execution only. This should be a string formatted as {width}x{height}, for example 1024x768.
userAgent
(Optional) Alternate user agent to use for this execution only
region
(Optional) Geo-location for test execution. The following options are available: us-east-1 (default), us-west-1, ca-central-1, eu-central-1, eu-west-1, eu-west-2, ap-northeast-1, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-south-1, sa-east-1
httpAuthUsername
(Optional) Alternate HTTP authentication username to use for this execution only
httpAuthPassword
(Optional) Alternate HTTP authentication password to use for this execution only
webhook
(Optional) An escaped URL (or array of URLs) added to the webhooks list for this execution only
disableNotifications
(Optional) Use 1 to disable all notifications for this execution only
immediate
(Optional) Use 1 to initiate the execution, then immediate return a response (without results)
dataFile
(Optional) A CSV file containing a row of variable values for each test run as outlined in our data-driven testing section. A POST request must be used when sending this file. When included, an array of test results will be returned, instead of a single result.
[varName]
(Optional) Pass in custom variables for the test run that are accessible in your steps via {{varName}}. For example, including &firstName=Justin in the API call will create a {{firstName}} variable with the value Justin.
Response
{
  "code": "SUCCESS",
  "data": {
    "_id": "5351669ce0d6891bf054be1b",
    "dateExecutionFinished": "2014-04-18T17:53:42.148Z",
    "dateExecutionStarted": "2014-04-18T17:53:32.188Z",
    "startUrl": "https://www.google.com/",
    "endUrl": "https://www.google.com/#q=ghosts",
    "test": {
      "_id": "5335c6a5f6d88b3069f1ac06",
      "name": "Google Test",
      "suite": "5330e25967076985585532fb",
      "organization" : "52df0d27fbaced54db000006"
    },
    "screenshot": {
      "small": {
        "depth": 8,
        "format": "PNG",
        "oname": "5351669ce0d6891bf054be1b.png",
        "mtime": "2014-04-18T17:53:42.000Z",
        "ctime": "2014-04-18T17:53:42.000Z",
        "size": 111709,
        "path": "/screenshots/5351669ce0d6891bf054be1b-small.png",
        "defaultUrl": "https://ghostinspector.s3.amazonaws.com/screenshots/5351669ce0d6891bf054be1b-small.png",
        "dims": {
          "w": 320,
          "h": 720
        }
      },
      "original": {
        "depth": 8,
        "format": "PNG",
        "oname": "5351669ce0d6891bf054be1b.png",
        "mtime": "2014-04-18T17:53:42.000Z",
        "ctime": "2014-04-18T17:53:42.000Z",
        "size": 446945,
        "path": "/screenshots/5351669ce0d6891bf054be1b-original.png",
        "defaultUrl": "https://ghostinspector.s3.amazonaws.com/screenshots/5351669ce0d6891bf054be1b-original.png",
        "dims": {
          "w": 1024,
          "h": 2305
        }
      }
    },
    "screenshotCompareDifference": null,
    "screenshotComparePassing": null,
    "video": {
      "dims": {
        "w": 1024,
        "h": 768
      },
      "path": "/videos/5351669ce0d6891bf054be1b.mp4",
      "url": "https://ghostinspector.s3.amazonaws.com/videos/5351669ce0d6891bf054be1b.mp4"
    },
    "passing": true,
    "console": [],
    "steps": [
      {
        "command": "click",
        "target": "#gbqfq",
        "url": "https://www.google.com/",
        "dateExecuted": "2014-04-18T17:53:35.170Z",
        "_id": "5351669fe0d6891bf054be1c",
        "passing": true,
        "private": false,
        "sequence": 0
      },
      {
        "command": "assign",
        "target": "#gbqfq",
        "value": "ghosts",
        "url": "https://www.google.com/",
        "dateExecuted": "2014-04-18T17:53:35.584Z",
        "_id": "5351669fe0d6891bf054be1d",
        "passing": true,
        "private": false,
        "sequence": 1
      },
      {
        "command": "keypress",
        "target": "#gbqfq",
        "value": "13",
        "url": "https://www.google.com/",
        "dateExecuted": "2014-04-18T17:53:35.954Z",
        "_id": "5351669fe0d6891bf054be1e",
        "passing": true,
        "private": false,
        "sequence": 2
      },
      {
        "command": "assertElementPresent",
        "target": "#resultStats",
        "value": "",
        "url": "https://www.google.com/",
        "dateExecuted": "2014-04-18T17:53:36.670Z",
        "_id": "535166a0e0d6891bf054be1f",
        "passing": true,
        "private": false,
        "sequence": 3
      }
    ],
    "extractions": {
      "token": "1234567890"
    },
    "viewportSize": {
      "height": 768,
      "width": 1024
    }
  }
}


List Test Results

Fetch an array containing the results for a test. Results are returned in reverse chronological order (newest first).

Request
GEThttps://api.ghostinspector.com/v1/tests/<testId>/results/?apiKey=<apiKey>
Parameters
apiKey
Your API key provided in your account
testId
The ID of the test containing the results
count
The number of results to return (default 10, maximum 50)
offset
The number of results to offset the returned set by (default 0)
Response
{
  "code": "SUCCESS",
  "data": [
    {
      "_id": "5335c6a6eecee7735866df68",
      "dateExecutionFinished": "2014-03-28T19:00:01.861Z",
      "dateExecutionStarted": "2014-03-28T18:59:50.863Z",
      "startUrl": "https://www.google.com/",
      "endUrl": "https://www.google.com/#q=ghosts",
      "test": {
        "_id": "5335c6a5f6d88b3069f1ac06",
        "name": "Google Test",
        "suite": "5330e25967076985585532fb",
        "organization" : "52df0d27fbaced54db000006"
      },
      "screenshot": {
        "small": {
          "depth": 8,
          "format": "PNG",
          "oname": "5335c6a6eecee7735866df68.png",
          "mtime": "2014-03-28T19:00:02.000Z",
          "ctime": "2014-03-28T19:00:02.000Z",
          "size": 12522,
          "path": "/screenshots/5335c6a6eecee7735866df68-small.png",
          "defaultUrl": "https://ghostinspector.s3.amazonaws.com/screenshots/5335c6a6eecee7735866df68-small.png",
          "dims": {
            "w": 320,
            "h": 240
          }
        },
        "original": {
          "depth": 8,
          "format": "PNG",
          "oname": "5335c6a6eecee7735866df68.png",
          "mtime": "2014-03-28T19:00:01.000Z",
          "ctime": "2014-03-28T19:00:01.000Z",
          "size": 39013,
          "path": "/screenshots/5335c6a6eecee7735866df68-original.png",
          "defaultUrl": "https://ghostinspector.s3.amazonaws.com/screenshots/5335c6a6eecee7735866df68-original.png",
          "dims": {
            "w": 1024,
            "h": 768
          }
        }
      },
      "screenshotCompareDifference": null,
      "screenshotComparePassing": null,
      "video": {
        "dims": {
          "w": 1024,
          "h": 768
        },
        "path": "/videos/53516d4fe0d6891bf054be20.mp4",
        "url": "https://ghostinspector.s3.amazonaws.com/videos/53516d4fe0d6891bf054be20.mp4"
      },
      "passing": false,
      "console": [...],
      "steps": [...],
      "extractions": {...},
      "viewportSize": {
        "height": 768,
        "width": 1024
      }
    },
    {
      "_id": "5338ab0573b3e7c25c5b1801",
      "dateExecutionFinished": "2014-03-30T23:38:58.163Z",
      "dateExecutionStarted": "2014-03-30T23:38:45.906Z",
      "startUrl": "https://www.google.com/",
      "endUrl": "https://www.google.com/#q=ghosts",
      "test": {
        "_id": "5335c6a5f6d88b3069f1ac06",
        "name": "Google Test",
        "suite": "5330e25967076985585532fb",
        "organization" : "52df0d27fbaced54db000006"
      },
      "screenshot": {
        "small": {
          "depth": 8,
          "format": "PNG",
          "oname": "5338ab0573b3e7c25c5b1801.png",
          "mtime": "2014-03-30T23:38:58.000Z",
          "ctime": "2014-03-30T23:38:58.000Z",
          "size": 12754,
          "path": "/screenshots/5338ab0573b3e7c25c5b1801-small.png",
          "defaultUrl": "https://ghostinspector.s3.amazonaws.com/screenshots/5338ab0573b3e7c25c5b1801-small.png",
          "dims": {
            "w": 320,
            "h": 240
          }
        },
        "original": {
          "depth": 8,
          "format": "PNG",
          "oname": "5338ab0573b3e7c25c5b1801.png",
          "mtime": "2014-03-30T23:38:58.000Z",
          "ctime": "2014-03-30T23:38:58.000Z",
          "size": 43294,
          "path": "/screenshots/5338ab0573b3e7c25c5b1801-original.png",
          "defaultUrl": "https://ghostinspector.s3.amazonaws.com/screenshots/5338ab0573b3e7c25c5b1801-original.png",
          "dims": {
            "w": 1024,
            "h": 768
          }
        }
      },
      "screenshotCompareDifference": null,
      "screenshotComparePassing": null,
      "video": {
        "dims": {
          "w": 1024,
          "h": 768
        },
        "path": "/videos/53516d4fe0d6891bf054be20.mp4",
        "url": "https://ghostinspector.s3.amazonaws.com/videos/53516d4fe0d6891bf054be20.mp4"
      },
      "passing": false,
      "console": [...],
      "steps": [...],
      "extractions": {...},
      "viewportSize": {
        "height": 768,
        "width": 1024
      }
    }
  ]
}


Download in Selenium 1 Format (HTML)

Download a single test in Selenium 1 format (HTML).

Request
GEThttps://api.ghostinspector.com/v1/tests/<testId>/export/selenium-html/?apiKey=<apiKey>
Parameters
apiKey
Your API key provided in your account
testId
The ID of the test to fetch
Response
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="https://ghostinspector.com" />
<title>Sample Test</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr>
<td rowspan="1" colspan="3">Sample Test</td>
</tr>
</thead>
<tbody>
<tr>
<td>open</td>
<td>/</td>
<td></td>
</tr>
<tr>
<td>waitForPageToLoad</td>
<td></td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>css=#username</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>css=#username</td>
<td>test</td>
</tr>
<tr>
<td>waitForPageToLoad</td>
<td></td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>css=#submit</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=#submit</td>
<td></td>
</tr>
</tbody>
</table>
</body>
</html>


Download in Selenium 2 Format (JSON)

Download a single test in Selenium 2 format (JSON).

Request
GEThttps://api.ghostinspector.com/v1/tests/<testId>/export/selenium-json/?apiKey=<apiKey>
Parameters
apiKey
Your API key provided in your account
testId
The ID of the test to fetch
Response
{
  "type": "script",
  "seleniumVersion": "2",
  "formatVersion": 2,
  "steps": [
    {
      "type": "get",
      "url": "http://www.example.com/"
    },
    {
      "type": "waitForElementPresent",
      "locator": {
        "type": "css selector",
        "value": "#header"
      }
    },
    {
      "type": "assertTextPresent",
      "locator": {
        "type": "css selector",
        "value": "#header"
      },
      "text": "Dashboard",
      "negated": false
    }
  ]
}