playwrightcucumberjslambdatest

How to get LambdaTest session ID from within Playwright tests?


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?


Solution

  • 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