Skip to main content
Transform your testing process with: Real Device Features, Company-wide Licences, & Test Observability

Get Session Details of Puppeteer Tests

A guide to getting all the details related to a Puppeteer test session running on BrowserStack

Details of a Puppeteer test session on BrowserStack

When a Puppeteer test runs on BrowserStack, a lot of logs are generated including Video, Text Logs, Network Logs etc. and also each session that runs on BrowserStack has a unique identifier that can be used to invoke multiple different REST API calls to achieve different purposes.

We’ve created a simple executor that you can run from within your Puppeteer test script and get all the relevant details of that session as a JSON response that you can later use even after the script has completed its execution.

How to get the details of a Puppeteer session?

You can use the snippet provided below anywhere in any of your Puppeteer scripts and you would get the details as a JSON response as shown in the next section.

const resp = await JSON.parse(await page.evaluate(_ => {}, `browserstack_executor: ${JSON.stringify({action: 'getSessionDetails'})}`));
console.log(resp);  // This prints the entire JSON response on the console. You can use the data in this variable even outside the test script if you save it appropriately

You can also see the sample script where the getSessionDetails executor is shown in action.

Session details JSON

The JSON response that you would get on executing the above script is as shown below:

Sample JSON response
{
  name: 'My first Puppeteer test',
  duration: null,
  os: 'OS X',
  os_version: 'Big Sur',
  browser_version: '103.0',
  browser: 'chrome',
  device: null,
  status: 'running',
  hashed_id: '692e4a82f79007a898ebd70dce8e76741de7b772',
  reason: null,
  build_name: 'puppeteer-build-1',
  project_name: 'Untitled Project',
  build_hashed_id: 'cd4704a11337c1754b1096e7e391e6514476ed67',
  test_priority: null,
  logs: 'https://automate.browserstack.com/builds/cd4704a11337c1754b1096e7e391e6514476ed67/sessions/692e4a82f79007a898ebd70dce8e76741de7b772/logs',
  browserstack_status: 'running',
  created_at: '2022-07-21T07:11:49.000Z',
  browser_url: 'https://automate.browserstack.com/builds/cd4704a11337c1754b1096e7e391e6514476ed67/sessions/692e4a82f79007a898ebd70dce8e76741de7b772',
  public_url: 'https://automate.browserstack.com/builds/cd4704a11337c1754b1096e7e391e6514476ed67/sessions/692e4a82f79007a898ebd70dce8e76741de7b772?auth_token=d5ba9e5e8476f1e74579d4948de69eb97ea6ae4631457c49c31e6d4eb2b9be74',
  video_url: 'https://automate.browserstack.com/sessions/692e4a82f79007a898ebd70dce8e76741de7b772/video?token=ajVXVWhOWG1QS1BhdkdoSTNONEk2a2ZNWjdTTVlXR283cWw5dzRVTGM4NGZVWjlwZmxwRnpPQm5RVllnRW56U0c1SHpabXlaSHdzQ05QbUxDOURmUFE9PS0tN1dPZFdpOWtNNlExYkZkVnNjQzFtdz09--3a09bef56432c379c9c3957a7800ce98dbf61d7a&source=rest_api&diff=-1',
  browser_console_logs_url: 'https://automate.browserstack.com/s3-upload/bs-selenium-logs-aps/s3.ap-south-1/692e4a82f79007a898ebd70dce8e76741de7b772/692e4a82f79007a898ebd70dce8e76741de7b772-console-logs-v2.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIA2XUQHUQMELHN7PNX%2F20220721%2Fap-south-1%2Fs3%2Faws4_request&X-Amz-Date=20220721T071158Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=235ee83b70bf2ca2729ee6dc392c3612c1229d131e27ade0a3e11da825045105',
  har_logs_url: 'https://automate.browserstack.com/s3-upload/bs-selenium-logs-aps/s3.ap-south-1/692e4a82f79007a898ebd70dce8e76741de7b772/692e4a82f79007a898ebd70dce8e76741de7b772-har-logs.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIA2XUQHUQMELHN7PNX%2F20220721%2Fap-south-1%2Fs3%2Faws4_request&X-Amz-Date=20220721T071158Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=47fda0a0af740c778bf2f2767552659b0af722125f9e5081fd8249e69a315735',
  terminal_logs_url: null
}

You can use the hashed_id and build_hashed_id to invoke the REST APIs. You can read more in the Puppeteer REST API documentation for BrowserStack.

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback!

Talk to an Expert
Download Copy