How to get LambdaTest session ID from within Playwright tests?

195 views Asked by At

I have automation tests written in Playwright, I'm using CucumberJS with it and my tests are running on LambdaTest. Inside my code I want to print LambdaTest session ID that is generated for each scenario. How to do it? Tried already

let response = JSON.parse(await page.evaluate(() => {}, 'lambdatest_action: ${JSON.stringify({action: "getSessionDetails"})}'));

console.info('Test ID is ${response.data.session_id}');

and it was working fine for some time but now it doesn't (have no idea why). Do you have any other ideas?

1

There are 1 answers

0
Abid Kidwai On BEST ANSWER

Yes, you can use the below code snippet to fetch the session information.

let response = JSON.parse(await page.evaluate(_ => {}, lambdatest_action: ${JSON.stringify({ action: 'getTestDetails' })}))
console.log(response);

Ref