Features

Get Playwright Session Details

When a Playwright test runs on TestingBot, it will generate various artifacts such as logs, video, screenshots and other files.
TestingBot will save these files for later retrieval, through our member dashboard or our REST API.

To fetch these details through our REST API, you will need to know the unique identifier for each test.
TestingBot provides a sessionId which you can retrieve, to use in your REST API calls.

Fetch the sessionId

To fetch the sessionId in your Playwright script, you can parse the sessionId from the browser.userAgent() method.

See the example below, where we run a Playwright script, fetch the sessionId at the end and update the test status via our REST API.

const TestingBot = require('testingbot-api');
const tb = new TestingBot({
    api_key: 'api_key',
    api_secret: 'api_secret'
})

const olaywright = require('playwright-core');

(async () => {
    const browser = await playwright.connect({
      browserWSEndpoint: 'wss://cloud.testingbot.com/playwright?key=api_key&secret=api_secret&browserName=chrome&browserVersion=latest&platform=WIN10'
    })

    const page = await browser.newPage()
    await page.goto('https://testingbot.com')
    const userAgent = await browser.userAgent()
    const sessionId = userAgent.sessionId

    var testData = { "test[success]" : "1", "test[status_message]" : "test" };
    await new Promise((resolve) => tb.updateTest(testData, sessionId, function(error, testDetails) { resolve(testDetails) }))

    browser.close()
})()