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 testingbot_executor
which you can use to retrieve the sessionId
, to use in your REST API calls.
Fetch the sessionId
To fetch the sessionId in your Playwright script, you can fetch the sessionId
from the getSessionDetails
method.
See the example below, where we run a Playwright script, fetch the getSessionDetails
at the end and update the test status via the TestingBot REST API.
const TestingBot = require('testingbot-api');
const tb = new TestingBot({
api_key: 'api_key',
api_secret: 'api_secret'
})
const playwright = 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 testingBotResponse = await page.evaluate(_ => {}, `testingbot_executor: ${JSON.stringify({action: 'getSessionDetails'})}`)
const sessionId = testingBotResponse.sessionId
const testData = { "test[success]" : "1", "test[status_message]" : "test" };
await new Promise((resolve) => tb.updateTest(testData, sessionId, function(error, testDetails) { resolve(testDetails) }))
await browser.close()
})()